Issue #18192: Introduce importlib.util.MAGIC_NUMBER and document the

deprecation of imp.get_magic().
This commit is contained in:
Brett Cannon 2013-06-14 19:02:34 -04:00
parent 4d7056258b
commit 05a647deed
8 changed files with 37 additions and 8 deletions

View file

@ -313,5 +313,16 @@ class ResolveNameTests(unittest.TestCase):
util.resolve_name('..bacon', 'spam')
class MagicNumberTests(unittest.TestCase):
def test_length(self):
# Should be 4 bytes.
self.assertEqual(len(util.MAGIC_NUMBER), 4)
def test_incorporates_rn(self):
# The magic number uses \r\n to come out wrong when splitting on lines.
self.assertTrue(util.MAGIC_NUMBER.endswith(b'\r\n'))
if __name__ == '__main__':
unittest.main()