Mercurial > p > roundup > code
comparison test/test_hypothesis.py @ 7902:2c6d66819475
fix: missing crypt in python with hypothesis testing.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 20 Apr 2024 17:14:08 -0400 |
| parents | 9ff94a2e8c82 |
| children |
comparison
equal
deleted
inserted
replaced
| 7901:9ff94a2e8c82 | 7902:2c6d66819475 |
|---|---|
| 47 @settings(max_examples=_max_examples) | 47 @settings(max_examples=_max_examples) |
| 48 def test_h64encode_h64decode(self, s): | 48 def test_h64encode_h64decode(self, s): |
| 49 | 49 |
| 50 self.assertEqual(h64decode(h64encode(s)), s) | 50 self.assertEqual(h64decode(h64encode(s)), s) |
| 51 | 51 |
| 52 crypt_modes = ["PBKDF2S5", "PBKDF2", "SSHA", "SHA", "MD5", | |
| 53 "plaintext", "zot"] | |
| 54 if crypt_method: | |
| 55 crypt_modes.append("crypt") | |
| 56 | |
| 52 @given(one_of(none(), text()), | 57 @given(one_of(none(), text()), |
| 53 sampled_from(("PBKDF2S5", "PBKDF2", "SSHA", | 58 sampled_from(crypt_modes)) |
| 54 "SHA", "MD5", "crypt", "plaintext", | |
| 55 "zot"))) | |
| 56 @example("asd\x00df", "crypt") | 59 @example("asd\x00df", "crypt") |
| 57 @settings(max_examples=_max_examples) | 60 @settings(max_examples=_max_examples) # deadline=None for debugging |
| 58 def test_encodePassword(self, password, scheme): | 61 def test_encodePassword(self, password, scheme): |
| 59 | 62 |
| 60 if scheme == "crypt" and password and "\x00" in password: | 63 if scheme == "crypt" and password and "\x00" in password: |
| 61 with self.assertRaises(ValueError) as e: | 64 with self.assertRaises(ValueError) as e: |
| 62 encodePassword(password, scheme) | 65 encodePassword(password, scheme) |
