|
2 | 2 |
|
3 | 3 | from atbash_cipher import decode, encode
|
4 | 4 |
|
5 |
| - |
6 | 5 | # Tests adapted from `problem-specifications//canonical-data.json` @ v1.2.0
|
7 | 6 |
|
8 |
| -class AtbashCipherTest(unittest.TestCase): |
9 |
| - def test_encode_no(self): |
10 |
| - self.assertMultiLineEqual(encode("no"), "ml") |
11 | 7 |
|
| 8 | +class AtbashCipherTest(unittest.TestCase): |
12 | 9 | def test_encode_yes(self):
|
13 |
| - self.assertMultiLineEqual(encode("yes"), "bvh") |
| 10 | + self.assertEqual(encode("yes"), "bvh") |
14 | 11 |
|
15 |
| - def test_encode_OMG(self): |
16 |
| - self.assertMultiLineEqual(encode("OMG"), "lnt") |
| 12 | + def test_encode_no(self): |
| 13 | + self.assertEqual(encode("no"), "ml") |
| 14 | + |
| 15 | + def test_encode_omg(self): |
| 16 | + self.assertEqual(encode("OMG"), "lnt") |
17 | 17 |
|
18 |
| - def test_encode_O_M_G(self): |
19 |
| - self.assertMultiLineEqual(encode("O M G"), "lnt") |
| 18 | + def test_encode_spaces(self): |
| 19 | + self.assertEqual(encode("O M G"), "lnt") |
20 | 20 |
|
21 |
| - def test_encode_long_word(self): |
22 |
| - self.assertMultiLineEqual(encode("mindblowingly"), "nrmwy oldrm tob") |
| 21 | + def test_encode_mindblowingly(self): |
| 22 | + self.assertEqual(encode("mindblowingly"), "nrmwy oldrm tob") |
23 | 23 |
|
24 | 24 | def test_encode_numbers(self):
|
25 |
| - self.assertMultiLineEqual( |
26 |
| - encode("Testing, 1 2 3, testing."), "gvhgr mt123 gvhgr mt") |
| 25 | + self.assertEqual(encode("Testing,1 2 3, testing."), "gvhgr mt123 gvhgr mt") |
27 | 26 |
|
28 |
| - def test_encode_sentence(self): |
29 |
| - self.assertMultiLineEqual( |
30 |
| - encode("Truth is fiction."), "gifgs rhurx grlm") |
| 27 | + def test_encode_deep_thought(self): |
| 28 | + self.assertEqual(encode("Truth is fiction."), "gifgs rhurx grlm") |
31 | 29 |
|
32 |
| - def test_encode_all_things(self): |
33 |
| - plaintext = "The quick brown fox jumps over the lazy dog." |
34 |
| - ciphertext = "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt" |
35 |
| - self.assertMultiLineEqual(encode(plaintext), ciphertext) |
| 30 | + def test_encode_all_the_letters(self): |
| 31 | + self.assertEqual( |
| 32 | + encode("The quick brown fox jumps over the lazy dog."), |
| 33 | + "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt", |
| 34 | + ) |
36 | 35 |
|
37 |
| - def test_decode_word(self): |
38 |
| - self.assertMultiLineEqual(decode("vcvix rhn"), "exercism") |
| 36 | + def test_decode_exercism(self): |
| 37 | + self.assertEqual(decode("vcvix rhn"), "exercism") |
39 | 38 |
|
40 |
| - def test_decode_sentence(self): |
41 |
| - self.assertMultiLineEqual( |
| 39 | + def test_decode_a_sentence(self): |
| 40 | + self.assertEqual( |
42 | 41 | decode("zmlyh gzxov rhlug vmzhg vkkrm thglm v"),
|
43 |
| - "anobstacleisoftenasteppingstone") |
| 42 | + "anobstacleisoftenasteppingstone", |
| 43 | + ) |
44 | 44 |
|
45 | 45 | def test_decode_numbers(self):
|
46 |
| - self.assertMultiLineEqual( |
47 |
| - decode("gvhgr mt123 gvhgr mt"), "testing123testing") |
| 46 | + self.assertEqual(decode("gvhgr mt123 gvhgr mt"), "testing123testing") |
48 | 47 |
|
49 | 48 | def test_decode_all_the_letters(self):
|
50 |
| - ciphertext = "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt" |
51 |
| - plaintext = "thequickbrownfoxjumpsoverthelazydog" |
52 |
| - self.assertMultiLineEqual(decode(ciphertext), plaintext) |
| 49 | + self.assertEqual( |
| 50 | + decode("gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"), |
| 51 | + "thequickbrownfoxjumpsoverthelazydog", |
| 52 | + ) |
53 | 53 |
|
54 | 54 | def test_decode_with_too_many_spaces(self):
|
55 |
| - self.assertMultiLineEqual(decode("vc vix r hn"), "exercism") |
| 55 | + self.assertEqual(decode("vc vix r hn"), "exercism") |
56 | 56 |
|
57 | 57 | def test_decode_with_no_spaces(self):
|
58 |
| - ciphertext = "zmlyhgzxovrhlugvmzhgvkkrmthglmv" |
59 |
| - plaintext = "anobstacleisoftenasteppingstone" |
60 |
| - self.assertMultiLineEqual(decode(ciphertext), plaintext) |
61 |
| - |
62 |
| - # additional track specific test |
63 |
| - def test_encode_decode(self): |
64 |
| - self.assertMultiLineEqual( |
65 |
| - decode(encode("Testing, 1 2 3, testing.")), "testing123testing") |
| 58 | + self.assertEqual( |
| 59 | + decode("zmlyhgzxovrhlugvmzhgvkkrmthglmv"), "anobstacleisoftenasteppingstone" |
| 60 | + ) |
66 | 61 |
|
67 | 62 |
|
68 |
| -if __name__ == '__main__': |
| 63 | +if __name__ == "__main__": |
69 | 64 | unittest.main()
|
0 commit comments