class_docstr: Tests for Importer and derived classes.
docstr: OrderedImporter's implementation of whichmodule should try each
  underlying importer's whichmodule in order.
code: def test_ordered_importer_whichmodule(self):
      """OrderedImporter's implementation of whichmodule should try each
      underlying importer's whichmodule in order.
      """
  
      class DummyImporter(Importer):
          def __init__(self, whichmodule_return):
              self._whichmodule_return = whichmodule_return
  
          def import_module(self, module_name):
              raise NotImplementedError()
  
          def whichmodule(self, obj, name):
              return self._whichmodule_return
  
      class DummyClass:
          pass
  
      dummy_importer_foo = DummyImporter("foo")
      dummy_importer_bar = DummyImporter("bar")
      dummy_importer_not_found = DummyImporter(
          "__main__"
      )  # __main__ is used as a proxy for "not found" by CPython
  
      foo_then_bar = OrderedImporter(
          dummy_importer_foo, dummy_importer_bar
      )
      self.assertEqual(
          foo_then_bar.whichmodule(DummyClass(), ""), "foo"
      )
  
      bar_then_foo = OrderedImporter(
          dummy_importer_bar, dummy_importer_foo
      )
      self.assertEqual(
          bar_then_foo.whichmodule(DummyClass(), ""), "bar"
      )
  
      notfound_then_foo = OrderedImporter(
          dummy_importer_not_found, dummy_importer_foo
      )
      self.assertEqual(
          notfound_then_foo.whichmodule(DummyClass(), ""), "foo"
      )
  
file_path: pytorch/test/package/test_importer.py
imports: from io import BytesIO
  import torch
  from torch.package import Importer, OrderedImporter, PackageExporter, PackageImporter, sys_importer
  from torch.testing._internal.common_utils import run_tests
label_desc: Use image node_id 5 for calling the TestImporter obj's underlying member method code with example usage: obj.test_ordered_importer_whichmodule() and returns: self