MCPcopy Index your code
hub / github.com/python/cpython / test_get_source

Method test_get_source

Lib/test/test_importlib/test_abc.py:615–625  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

613 """Test importlib.abc.SourceLoader for source-only loading."""
614
615 def test_get_source(self):
616 # Verify the source code is returned as a string.
617 # If an OSError is raised by get_data then raise ImportError.
618 expected_source = self.loader.source.decode('utf-8')
619 self.assertEqual(self.loader.get_source(self.name), expected_source)
620 def raise_OSError(path):
621 raise OSError
622 self.loader.get_data = raise_OSError
623 with self.assertRaises(ImportError) as cm:
624 self.loader.get_source(self.name)
625 self.assertEqual(cm.exception.name, self.name)
626
627 def test_is_package(self):
628 # Properly detect when loading a package.

Callers

nothing calls this directly

Calls 4

decodeMethod · 0.45
assertEqualMethod · 0.45
get_sourceMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected