ยปCore Development>Code coverage>Lib/test/test_crypt.py

Python code coverage for Lib/test/test_crypt.py

#countcontent
1n/afrom test import support
2n/aimport unittest
3n/a
4n/acrypt = support.import_module('crypt')
5n/a
6n/aclass CryptTestCase(unittest.TestCase):
7n/a
8n/a def test_crypt(self):
9n/a c = crypt.crypt('mypassword', 'ab')
10n/a if support.verbose:
11n/a print('Test encryption: ', c)
12n/a
13n/a def test_salt(self):
14n/a self.assertEqual(len(crypt._saltchars), 64)
15n/a for method in crypt.methods:
16n/a salt = crypt.mksalt(method)
17n/a self.assertEqual(len(salt),
18n/a method.salt_chars + (3 if method.ident else 0))
19n/a
20n/a def test_saltedcrypt(self):
21n/a for method in crypt.methods:
22n/a pw = crypt.crypt('assword', method)
23n/a self.assertEqual(len(pw), method.total_size)
24n/a pw = crypt.crypt('assword', crypt.mksalt(method))
25n/a self.assertEqual(len(pw), method.total_size)
26n/a
27n/a def test_methods(self):
28n/a # Guarantee that METHOD_CRYPT is the last method in crypt.methods.
29n/a self.assertTrue(len(crypt.methods) >= 1)
30n/a self.assertEqual(crypt.METHOD_CRYPT, crypt.methods[-1])
31n/a
32n/aif __name__ == "__main__":
33n/a unittest.main()