class_docstr: Tests for PathFinder.
class_docstr_tok: ["Tests","for","PathFinder","."]
code: def test_finder_with_find_spec(self):
      class TestFinder:
          spec = None
  
          def find_spec(self, fullname, target=None):
              return self.spec
  
      path = "testing path"
      with util.import_state(path_importer_cache={path: TestFinder()}):
          self.assertIsNone(
              self.machinery.PathFinder.find_spec("whatever", [path])
          )
      success_finder = TestFinder()
      success_finder.spec = self.machinery.ModuleSpec(
          "whatever", __loader__
      )
      with util.import_state(
          path_importer_cache={path: success_finder}
      ):
          got = self.machinery.PathFinder.find_spec("whatever", [path])
      self.assertEqual(got, success_finder.spec)
  
imports: from test.test_importlib import util
  import os
  import sys
  import tempfile
  from types import ModuleType
  import unittest
  import warnings
  import zipimport
label_desc: Use image node_id 9 for calling the FinderTests obj's underlying member method code with example usage: obj.test_finder_with_find_spec() and returns: self