Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(49761)

Side by Side Diff: Lib/test/test_crypt.py

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_copyreg.py ('k') | Lib/test/test_dbm_gnu.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 from test import support 1 from test import support
2 import unittest 2 import unittest
3 3
4 crypt = support.import_module('crypt') 4 crypt = support.import_module('crypt')
5 5
6 class CryptTestCase(unittest.TestCase): 6 class CryptTestCase(unittest.TestCase):
7 7
8 def test_crypt(self): 8 def test_crypt(self):
9 c = crypt.crypt('mypassword', 'ab') 9 c = crypt.crypt('mypassword', 'ab')
10 if support.verbose: 10 if support.verbose:
11 print('Test encryption: ', c) 11 print('Test encryption: ', c)
12 12
13 def test_salt(self): 13 def test_salt(self):
14 self.assertEqual(len(crypt._saltchars), 64) 14 self.assertEqual(len(crypt._saltchars), 64)
15 for method in crypt.methods: 15 for method in crypt.methods:
16 salt = crypt.mksalt(method) 16 salt = crypt.mksalt(method)
17 self.assertEqual(len(salt), 17 self.assertEqual(len(salt),
18 method.salt_chars + (3 if method.ident else 0)) 18 method.salt_chars + (3 if method.ident else 0))
19 19
20 def test_saltedcrypt(self): 20 def test_saltedcrypt(self):
21 for method in crypt.methods: 21 for method in crypt.methods:
22 pw = crypt.crypt('assword', method) 22 pw = crypt.crypt('assword', method)
23 self.assertEqual(len(pw), method.total_size) 23 self.assertEqual(len(pw), method.total_size)
24 pw = crypt.crypt('assword', crypt.mksalt(method)) 24 pw = crypt.crypt('assword', crypt.mksalt(method))
25 self.assertEqual(len(pw), method.total_size) 25 self.assertEqual(len(pw), method.total_size)
26 26
27 def test_methods(self): 27 def test_methods(self):
28 # Gurantee that METHOD_CRYPT is the last method in crypt.methods. 28 # Gurantee that METHOD_CRYPT is the last method in crypt.methods.
29 self.assertTrue(len(crypt.methods) >= 1) 29 self.assertGreaterEqual(len(crypt.methods), 1)
30 self.assertEqual(crypt.METHOD_CRYPT, crypt.methods[-1]) 30 self.assertEqual(crypt.METHOD_CRYPT, crypt.methods[-1])
31 31
32 if __name__ == "__main__": 32 if __name__ == "__main__":
33 unittest.main() 33 unittest.main()
OLDNEW
« no previous file with comments | « Lib/test/test_copyreg.py ('k') | Lib/test/test_dbm_gnu.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+