trackler 2.0.8.27 → 2.0.8.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/common/exercises/simple-cipher/description.md +1 -1
- data/common/exercises/triangle/description.md +12 -23
- data/lib/trackler/version.rb +1 -1
- data/tracks/kotlin/config.json +5 -0
- data/tracks/kotlin/exercises/bank-account/build.gradle +32 -0
- data/tracks/kotlin/exercises/bank-account/src/example/kotlin/BankAccount.kt +27 -0
- data/tracks/kotlin/exercises/bank-account/src/main/kotlin/.keep +0 -0
- data/tracks/kotlin/exercises/bank-account/src/test/kotlin/BankAccountTest.kt +73 -0
- data/tracks/kotlin/exercises/settings.gradle +1 -0
- data/tracks/python/config.json +11 -11
- data/tracks/python/exercises/accumulate/accumulate_test.py +16 -14
- data/tracks/python/exercises/acronym/acronym_test.py +8 -7
- data/tracks/python/exercises/allergies/allergies_test.py +5 -6
- data/tracks/python/exercises/atbash-cipher/atbash_cipher_test.py +16 -22
- data/tracks/python/exercises/binary-search/binary_search_test.py +12 -10
- data/tracks/python/exercises/binary/binary_test.py +7 -8
- data/tracks/python/exercises/circular-buffer/circular_buffer_test.py +16 -17
- data/tracks/python/exercises/clock/clock_test.py +35 -35
- data/tracks/python/exercises/crypto-square/crypto_square_test.py +5 -6
- data/tracks/python/exercises/diamond/diamond_test.py +3 -4
- data/tracks/python/exercises/etl/etl_test.py +4 -4
- data/tracks/python/exercises/gigasecond/gigasecond_test.py +11 -19
- data/tracks/python/exercises/grade-school/grade_school_test.py +17 -19
- data/tracks/python/exercises/grains/grains_test.py +14 -14
- data/tracks/python/exercises/grep/grep_test.py +51 -64
- data/tracks/python/exercises/hamming/hamming_test.py +13 -13
- data/tracks/python/exercises/hello-world/hello_world_test.py +1 -2
- data/tracks/python/exercises/hexadecimal/hexadecimal_test.py +9 -10
- data/tracks/python/exercises/house/house_test.py +6 -6
- data/tracks/python/exercises/kindergarten-garden/kindergarten_garden_test.py +22 -19
- data/tracks/python/exercises/largest-series-product/largest_series_product_test.py +29 -28
- data/tracks/python/exercises/linked-list/linked_list_test.py +18 -19
- data/tracks/python/exercises/list-ops/list_ops_test.py +44 -39
- data/tracks/python/exercises/matrix/matrix_test.py +6 -6
- data/tracks/python/exercises/meetup/meetup_test.py +27 -27
- data/tracks/python/exercises/minesweeper/example.py +4 -2
- data/tracks/python/exercises/minesweeper/minesweeper_test.py +9 -9
- data/tracks/python/exercises/nucleotide-count/nucleotide_count_test.py +6 -6
- data/tracks/python/exercises/ocr-numbers/ocr_numbers_test.py +63 -49
- data/tracks/python/exercises/octal/octal_test.py +7 -7
- data/tracks/python/exercises/palindrome-products/palindrome_products_test.py +9 -9
- data/tracks/python/exercises/pascals-triangle/pascals_triangle_test.py +7 -7
- data/tracks/python/exercises/phone-number/phone_number_test.py +8 -8
- data/tracks/python/exercises/pig-latin/pig_latin_test.py +15 -15
- data/tracks/python/exercises/point-mutations/point_mutations_test.py +11 -11
- data/tracks/python/exercises/poker/poker_test.py +32 -30
- data/tracks/python/exercises/prime-factors/prime_factors_test.py +11 -11
- data/tracks/python/exercises/proverb/proverb_test.py +16 -9
- data/tracks/python/exercises/pythagorean-triplet/pythagorean_triplet_test.py +14 -12
- data/tracks/python/exercises/queen-attack/queen_attack_test.py +10 -10
- data/tracks/python/exercises/rail-fence-cipher/example.py +2 -1
- data/tracks/python/exercises/rail-fence-cipher/rail_fence_cipher_test.py +14 -13
- data/tracks/python/exercises/raindrops/raindrops_test.py +16 -16
- data/tracks/python/exercises/rectangles/rectangles_test.py +9 -9
- data/tracks/python/exercises/rna-transcription/rna_transcription_test.py +8 -8
- data/tracks/python/exercises/robot-name/robot_name_test.py +1 -1
- data/tracks/python/exercises/robot-simulator/robot_simulator_test.py +18 -19
- data/tracks/python/exercises/roman-numerals/roman_numerals_test.py +1 -1
- data/tracks/python/exercises/run-length-encoding/run_length_encoding_test.py +15 -16
- data/tracks/python/exercises/saddle-points/saddle_points_test.py +4 -4
- data/tracks/python/exercises/say/say_test.py +21 -23
- data/tracks/python/exercises/scrabble-score/scrabble_score_test.py +9 -9
- data/tracks/python/exercises/secret-handshake/secret_handshake_test.py +14 -13
- data/tracks/python/exercises/series/example.py +3 -3
- data/tracks/python/exercises/series/series_test.py +16 -12
- data/tracks/python/exercises/simple-cipher/simple_cipher_test.py +21 -19
- data/tracks/python/exercises/space-age/space_age_test.py +16 -16
- data/tracks/python/exercises/strain/strain_test.py +9 -8
- data/tracks/python/exercises/sublist/sublist_test.py +19 -20
- data/tracks/python/exercises/sum-of-multiples/example.py +1 -4
- data/tracks/python/exercises/sum-of-multiples/sum_of_multiples_test.py +31 -26
- data/tracks/python/exercises/triangle/triangle_test.py +15 -30
- data/tracks/python/exercises/trinary/trinary_test.py +7 -7
- data/tracks/python/exercises/twelve-days/twelve_days_test.py +13 -14
- data/tracks/python/exercises/word-count/example.py +1 -9
- data/tracks/python/exercises/word-count/word_count_test.py +0 -15
- data/tracks/python/exercises/wordy/wordy_test.py +17 -18
- data/tracks/python/exercises/zebra-puzzle/example.py +20 -23
- data/tracks/python/exercises/zebra-puzzle/zebra_puzzle_test.py +3 -3
- data/tracks/python/test/check-exercises.py +1 -1
- metadata +6 -2
@@ -1,6 +1,6 @@
|
|
1
|
+
import unittest
|
1
2
|
from collections import Sequence
|
2
3
|
from types import GeneratorType
|
3
|
-
import unittest
|
4
4
|
|
5
5
|
from grade_school import School
|
6
6
|
|
@@ -14,40 +14,37 @@ class SchoolTest(unittest.TestCase):
|
|
14
14
|
|
15
15
|
def test_an_empty_school(self):
|
16
16
|
for n in range(1, 9):
|
17
|
-
self.assertCountEqual(
|
17
|
+
self.assertCountEqual(self.school.grade(n), set())
|
18
18
|
|
19
19
|
def test_add_student(self):
|
20
20
|
self.school.add("Aimee", 2)
|
21
|
-
self.assertCountEqual(
|
21
|
+
self.assertCountEqual(self.school.grade(2), ("Aimee", ))
|
22
22
|
|
23
23
|
def test_add_more_students_in_same_class(self):
|
24
24
|
self.school.add("James", 2)
|
25
25
|
self.school.add("Blair", 2)
|
26
26
|
self.school.add("Paul", 2)
|
27
|
-
self.assertCountEqual(("James", "Blair", "Paul")
|
27
|
+
self.assertCountEqual(self.school.grade(2), ("James", "Blair", "Paul"))
|
28
28
|
|
29
29
|
def test_add_students_to_different_grades(self):
|
30
30
|
self.school.add("Chelsea", 3)
|
31
31
|
self.school.add("Logan", 7)
|
32
|
-
self.assertCountEqual(
|
33
|
-
self.assertCountEqual(
|
32
|
+
self.assertCountEqual(self.school.grade(3), ("Chelsea", ))
|
33
|
+
self.assertCountEqual(self.school.grade(7), ("Logan", ))
|
34
34
|
|
35
35
|
def test_get_students_in_a_grade(self):
|
36
36
|
self.school.add("Franklin", 5)
|
37
37
|
self.school.add("Bradley", 5)
|
38
38
|
self.school.add("Jeff", 1)
|
39
|
-
self.assertCountEqual(("Franklin", "Bradley")
|
39
|
+
self.assertCountEqual(self.school.grade(5), ("Franklin", "Bradley"))
|
40
40
|
|
41
41
|
def test_get_students_in_a_non_existant_grade(self):
|
42
|
-
self.assertCountEqual(
|
42
|
+
self.assertCountEqual(self.school.grade(1), set())
|
43
43
|
|
44
44
|
def test_sort_school(self):
|
45
|
+
students = [(3, ("Kyle", )), (4, ("Christopher", "Jennifer", )),
|
46
|
+
(6, ("Kareem", ))]
|
45
47
|
|
46
|
-
students = [
|
47
|
-
(3, ("Kyle",)),
|
48
|
-
(4, ("Christopher", "Jennifer",)),
|
49
|
-
(6, ("Kareem",))
|
50
|
-
]
|
51
48
|
for grade, students_in_grade in students:
|
52
49
|
for student in students_in_grade:
|
53
50
|
self.school.add(student, grade)
|
@@ -55,14 +52,15 @@ class SchoolTest(unittest.TestCase):
|
|
55
52
|
result = self.school.sort()
|
56
53
|
|
57
54
|
# Attempts to catch false positives
|
58
|
-
self.assertTrue(
|
59
|
-
|
60
|
-
|
55
|
+
self.assertTrue(
|
56
|
+
isinstance(result, Sequence) or
|
57
|
+
isinstance(result, GeneratorType) or
|
58
|
+
callable(getattr(result, '__reversed__', False)))
|
61
59
|
|
62
|
-
result_list = list(result.items()
|
63
|
-
else result)
|
60
|
+
result_list = list(result.items()
|
61
|
+
if hasattr(result, "items") else result)
|
64
62
|
|
65
|
-
self.assertEqual(
|
63
|
+
self.assertEqual(students, result_list)
|
66
64
|
|
67
65
|
|
68
66
|
if __name__ == '__main__':
|
@@ -5,32 +5,32 @@ from grains import on_square, total_after
|
|
5
5
|
|
6
6
|
class GrainsTest(unittest.TestCase):
|
7
7
|
def test_square_1(self):
|
8
|
-
self.assertEqual(1,
|
9
|
-
self.assertEqual(1,
|
8
|
+
self.assertEqual(on_square(1), 1)
|
9
|
+
self.assertEqual(total_after(1), 1)
|
10
10
|
|
11
11
|
def test_square_2(self):
|
12
|
-
self.assertEqual(2,
|
13
|
-
self.assertEqual(
|
12
|
+
self.assertEqual(on_square(2), 2)
|
13
|
+
self.assertEqual(total_after(2), 3)
|
14
14
|
|
15
15
|
def test_square_3(self):
|
16
|
-
self.assertEqual(
|
17
|
-
self.assertEqual(
|
16
|
+
self.assertEqual(on_square(3), 4)
|
17
|
+
self.assertEqual(total_after(3), 7)
|
18
18
|
|
19
19
|
def test_square_4(self):
|
20
|
-
self.assertEqual(
|
21
|
-
self.assertEqual(
|
20
|
+
self.assertEqual(on_square(4), 8)
|
21
|
+
self.assertEqual(total_after(4), 15)
|
22
22
|
|
23
23
|
def test_square_16(self):
|
24
|
-
self.assertEqual(
|
25
|
-
self.assertEqual(
|
24
|
+
self.assertEqual(on_square(16), 32768)
|
25
|
+
self.assertEqual(total_after(16), 65535)
|
26
26
|
|
27
27
|
def test_square_32(self):
|
28
|
-
self.assertEqual(
|
29
|
-
self.assertEqual(
|
28
|
+
self.assertEqual(on_square(32), 2147483648)
|
29
|
+
self.assertEqual(total_after(32), 4294967295)
|
30
30
|
|
31
31
|
def test_square_64(self):
|
32
|
-
self.assertEqual(
|
33
|
-
self.assertEqual(
|
32
|
+
self.assertEqual(on_square(64), 9223372036854775808)
|
33
|
+
self.assertEqual(total_after(64), 18446744073709551615)
|
34
34
|
|
35
35
|
|
36
36
|
if __name__ == '__main__':
|
@@ -3,7 +3,6 @@ import unittest
|
|
3
3
|
|
4
4
|
from grep import grep
|
5
5
|
|
6
|
-
|
7
6
|
ILIADFILENAME = 'iliad.txt'
|
8
7
|
ILIADCONTENTS = '''Achilles sing, O Goddess! Peleus' son;
|
9
8
|
His wrath pernicious, who ten thousand woes
|
@@ -51,7 +50,6 @@ def create_file(name, contents):
|
|
51
50
|
|
52
51
|
|
53
52
|
class GrepTest(unittest.TestCase):
|
54
|
-
|
55
53
|
@classmethod
|
56
54
|
def setUpClass(self):
|
57
55
|
create_file(ILIADFILENAME, ILIADCONTENTS)
|
@@ -67,67 +65,57 @@ class GrepTest(unittest.TestCase):
|
|
67
65
|
def test_one_file_one_match_no_flags(self):
|
68
66
|
self.assertMultiLineEqual(
|
69
67
|
grep("Agamemnon", [ILIADFILENAME]),
|
70
|
-
"Of Atreus, Agamemnon, King of men.\n"
|
71
|
-
)
|
68
|
+
"Of Atreus, Agamemnon, King of men.\n")
|
72
69
|
|
73
70
|
def test_one_file_one_match_print_line_numbers_flag(self):
|
74
71
|
self.assertMultiLineEqual(
|
75
72
|
grep("Forbidden", [PARADISELOSTFILENAME], "-n"),
|
76
|
-
"2:Of that Forbidden Tree, whose mortal tast\n"
|
77
|
-
)
|
73
|
+
"2:Of that Forbidden Tree, whose mortal tast\n")
|
78
74
|
|
79
75
|
def test_one_file_one_match_case_insensitive_flag(self):
|
80
76
|
self.assertMultiLineEqual(
|
81
77
|
grep("FORBIDDEN", [PARADISELOSTFILENAME], "-i"),
|
82
|
-
"Of that Forbidden Tree, whose mortal tast\n"
|
83
|
-
)
|
78
|
+
"Of that Forbidden Tree, whose mortal tast\n")
|
84
79
|
|
85
80
|
def test_one_file_one_match_print_file_names_flag(self):
|
86
81
|
self.assertMultiLineEqual(
|
87
82
|
grep("Forbidden", [PARADISELOSTFILENAME], "-l"),
|
88
|
-
PARADISELOSTFILENAME + '\n'
|
89
|
-
)
|
83
|
+
PARADISELOSTFILENAME + '\n')
|
90
84
|
|
91
85
|
def test_one_file_one_match_match_entire_lines_flag(self):
|
92
86
|
self.assertMultiLineEqual(
|
93
|
-
grep("With loss of Eden, till one greater Man",
|
94
|
-
|
95
|
-
|
87
|
+
grep("With loss of Eden, till one greater Man",
|
88
|
+
[PARADISELOSTFILENAME], "-x"),
|
89
|
+
"With loss of Eden, till one greater Man\n")
|
96
90
|
|
97
91
|
def test_one_file_one_match_multiple_flags(self):
|
98
92
|
self.assertMultiLineEqual(
|
99
|
-
grep("OF ATREUS, Agamemnon, KIng of MEN.", [ILIADFILENAME],
|
100
|
-
|
101
|
-
)
|
93
|
+
grep("OF ATREUS, Agamemnon, KIng of MEN.", [ILIADFILENAME],
|
94
|
+
"-n -i -x"), "9:Of Atreus, Agamemnon, King of men.\n")
|
102
95
|
|
103
96
|
def test_one_file_several_matches_no_flags(self):
|
104
97
|
self.assertMultiLineEqual(
|
105
98
|
grep("may", [MIDSUMMERNIGHTFILENAME]),
|
106
99
|
("Nor how it may concern my modesty,\n"
|
107
100
|
"But I beseech your grace that I may know\n"
|
108
|
-
"The worst that may befall me in this case,\n")
|
109
|
-
)
|
101
|
+
"The worst that may befall me in this case,\n"))
|
110
102
|
|
111
103
|
def test_one_file_several_matches_print_line_numbers_flag(self):
|
112
104
|
self.assertMultiLineEqual(
|
113
105
|
grep("may", [MIDSUMMERNIGHTFILENAME], "-n"),
|
114
106
|
("3:Nor how it may concern my modesty,\n"
|
115
107
|
"5:But I beseech your grace that I may know\n"
|
116
|
-
"6:The worst that may befall me in this case,\n")
|
117
|
-
)
|
108
|
+
"6:The worst that may befall me in this case,\n"))
|
118
109
|
|
119
110
|
def test_one_file_several_matches_match_entire_lines_flag(self):
|
120
111
|
self.assertMultiLineEqual(
|
121
|
-
grep("may", [MIDSUMMERNIGHTFILENAME], "-x"),
|
122
|
-
""
|
123
|
-
)
|
112
|
+
grep("may", [MIDSUMMERNIGHTFILENAME], "-x"), "")
|
124
113
|
|
125
114
|
def test_one_file_several_matches_case_insensitive_flag(self):
|
126
115
|
self.assertMultiLineEqual(
|
127
116
|
grep("ACHILLES", [ILIADFILENAME], "-i"),
|
128
117
|
("Achilles sing, O Goddess! Peleus' son;\n"
|
129
|
-
"The noble Chief Achilles from the son\n")
|
130
|
-
)
|
118
|
+
"The noble Chief Achilles from the son\n"))
|
131
119
|
|
132
120
|
def test_one_file_several_matches_inverted_flag(self):
|
133
121
|
self.assertMultiLineEqual(
|
@@ -136,89 +124,88 @@ class GrepTest(unittest.TestCase):
|
|
136
124
|
"With loss of Eden, till one greater Man\n"
|
137
125
|
"Restore us, and regain the blissful Seat,\n"
|
138
126
|
"Sing Heav'nly Muse, that on the secret top\n"
|
139
|
-
"That Shepherd, who first taught the chosen Seed\n")
|
140
|
-
)
|
127
|
+
"That Shepherd, who first taught the chosen Seed\n"))
|
141
128
|
|
142
129
|
def test_one_file_no_matches_various_flags(self):
|
143
130
|
self.assertMultiLineEqual(
|
144
|
-
grep("Gandalf", [ILIADFILENAME], "-n -l -x -i"),
|
145
|
-
""
|
146
|
-
)
|
131
|
+
grep("Gandalf", [ILIADFILENAME], "-n -l -x -i"), "")
|
147
132
|
|
148
133
|
def test_multiple_files_one_match_no_flags(self):
|
149
134
|
self.assertMultiLineEqual(
|
150
|
-
grep(
|
151
|
-
|
152
|
-
|
135
|
+
grep(
|
136
|
+
"Agamemnon",
|
137
|
+
[ILIADFILENAME, MIDSUMMERNIGHTFILENAME, PARADISELOSTFILENAME]),
|
138
|
+
"iliad.txt:Of Atreus, Agamemnon, King of men.\n")
|
153
139
|
|
154
140
|
def test_multiple_files_several_matches_no_flags(self):
|
155
141
|
self.assertMultiLineEqual(
|
156
|
-
grep("may",
|
142
|
+
grep("may",
|
143
|
+
["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"]),
|
157
144
|
("midsummer-night.txt:Nor how it may concern my modesty,\n"
|
158
145
|
"midsummer-night.txt:But I beseech your grace that I may know\n"
|
159
|
-
"midsummer-night.txt:The worst that may befall me in this case,\n"
|
160
|
-
|
146
|
+
"midsummer-night.txt:The worst that may befall me in this case,\n"
|
147
|
+
))
|
161
148
|
|
162
149
|
def test_multiple_files_several_matches_print_line_numbers_flag(self):
|
163
150
|
self.assertMultiLineEqual(
|
164
|
-
grep("that",
|
151
|
+
grep("that",
|
152
|
+
["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
|
153
|
+
"-n"),
|
165
154
|
("midsummer-night.txt:5:But I beseech your grace that I may know\n"
|
166
|
-
"midsummer-night.txt:6:The worst that may befall me in this case
|
167
|
-
"
|
168
|
-
"
|
169
|
-
|
155
|
+
"midsummer-night.txt:6:The worst that may befall me in this case,"
|
156
|
+
"\nparadise-lost.txt:2:Of that Forbidden Tree, whose mortal tast"
|
157
|
+
"\nparadise-lost.txt:6:Sing Heav'nly Muse, that on the secret top"
|
158
|
+
"\n"))
|
170
159
|
|
171
160
|
def test_multiple_files_one_match_print_file_names_flag(self):
|
172
161
|
self.assertMultiLineEqual(
|
173
|
-
grep("who",
|
174
|
-
|
175
|
-
|
162
|
+
grep("who",
|
163
|
+
["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
|
164
|
+
"-l"), ILIADFILENAME + '\n' + PARADISELOSTFILENAME + '\n')
|
176
165
|
|
177
166
|
def test_multiple_files_several_matches_case_insensitive_flag(self):
|
178
167
|
self.assertMultiLineEqual(
|
179
|
-
grep("TO",
|
168
|
+
grep("TO",
|
169
|
+
["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
|
170
|
+
"-i"),
|
180
171
|
("iliad.txt:Caused to Achaia's host, sent many a soul\n"
|
181
172
|
"iliad.txt:Illustrious into Ades premature,\n"
|
182
173
|
"iliad.txt:And Heroes gave (so stood the will of Jove)\n"
|
183
174
|
"iliad.txt:To dogs and to all ravening fowls a prey,\n"
|
184
175
|
"midsummer-night.txt:I do entreat your grace to pardon me.\n"
|
185
|
-
"midsummer-night.txt:In such a presence here to plead my thoughts
|
186
|
-
"
|
187
|
-
"paradise-lost.txt:Brought Death into the World, and all our woe
|
188
|
-
"
|
189
|
-
"paradise-lost.txt:Sing Heav'nly Muse, that on the secret top\n")
|
190
|
-
)
|
176
|
+
"midsummer-night.txt:In such a presence here to plead my thoughts"
|
177
|
+
";\nmidsummer-night.txt:If I refuse to wed Demetrius.\n"
|
178
|
+
"paradise-lost.txt:Brought Death into the World, and all our woe,"
|
179
|
+
"\nparadise-lost.txt:Restore us, and regain the blissful Seat,\n"
|
180
|
+
"paradise-lost.txt:Sing Heav'nly Muse, that on the secret top\n"))
|
191
181
|
|
192
182
|
def test_multiple_files_several_matches_inverted_flag(self):
|
193
183
|
self.assertMultiLineEqual(
|
194
|
-
grep(
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
184
|
+
grep(
|
185
|
+
"a", ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
|
186
|
+
"-v"), ("iliad.txt:Achilles sing, O Goddess! Peleus' son;\n"
|
187
|
+
"iliad.txt:The noble Chief Achilles from the son\n"
|
188
|
+
"midsummer-night.txt:If I refuse to wed Demetrius.\n"))
|
199
189
|
|
200
190
|
def test_multiple_files_one_match_match_entire_lines_flag(self):
|
201
191
|
self.assertMultiLineEqual(
|
202
192
|
grep("But I beseech your grace that I may know",
|
203
193
|
["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
|
204
194
|
"-x"),
|
205
|
-
"midsummer-night.txt:But I beseech your grace that I may know\n"
|
206
|
-
)
|
195
|
+
"midsummer-night.txt:But I beseech your grace that I may know\n")
|
207
196
|
|
208
197
|
def test_multiple_files_one_match_multiple_flags(self):
|
209
198
|
self.assertMultiLineEqual(
|
210
199
|
grep("WITH LOSS OF EDEN, TILL ONE GREATER MAN",
|
211
200
|
["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
|
212
201
|
"-n -i -x"),
|
213
|
-
"paradise-lost.txt:4:With loss of Eden, till one greater Man\n"
|
214
|
-
)
|
202
|
+
"paradise-lost.txt:4:With loss of Eden, till one greater Man\n")
|
215
203
|
|
216
204
|
def test_multiple_files_no_matches_various_flags(self):
|
217
205
|
self.assertMultiLineEqual(
|
218
|
-
grep("Frodo",
|
219
|
-
"
|
220
|
-
|
221
|
-
)
|
206
|
+
grep("Frodo",
|
207
|
+
["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
|
208
|
+
"-n -l -x -i"), "")
|
222
209
|
|
223
210
|
|
224
211
|
if __name__ == '__main__':
|
@@ -8,43 +8,43 @@ import hamming
|
|
8
8
|
class HammingTest(unittest.TestCase):
|
9
9
|
|
10
10
|
def test_identical_strands(self):
|
11
|
-
self.assertEqual(
|
11
|
+
self.assertEqual(hamming.distance("A", "A"), 0)
|
12
12
|
|
13
13
|
def test_long_identical_strands(self):
|
14
|
-
self.assertEqual(
|
14
|
+
self.assertEqual(hamming.distance("GGACTGA", "GGACTGA"), 0)
|
15
15
|
|
16
16
|
def test_complete_distance_in_single_nucleotide_strands(self):
|
17
|
-
self.assertEqual(
|
17
|
+
self.assertEqual(hamming.distance("A", "G"), 1)
|
18
18
|
|
19
19
|
def test_complete_distance_in_small_strands(self):
|
20
|
-
self.assertEqual(
|
20
|
+
self.assertEqual(hamming.distance("AG", "CT"), 2)
|
21
21
|
|
22
22
|
def test_small_distance_in_small_strands(self):
|
23
|
-
self.assertEqual(
|
23
|
+
self.assertEqual(hamming.distance("AT", "CT"), 1)
|
24
24
|
|
25
25
|
def test_small_distance(self):
|
26
|
-
self.assertEqual(
|
26
|
+
self.assertEqual(hamming.distance("GGACG", "GGTCG"), 1)
|
27
27
|
|
28
28
|
def test_small_distance_in_long_strands(self):
|
29
|
-
self.assertEqual(
|
29
|
+
self.assertEqual(hamming.distance("ACCAGGG", "ACTATGG"), 2)
|
30
30
|
|
31
31
|
def test_non_unique_character_in_first_strand(self):
|
32
|
-
self.assertEqual(
|
32
|
+
self.assertEqual(hamming.distance("AGA", "AGG"), 1)
|
33
33
|
|
34
34
|
def test_non_unique_character_in_second_strand(self):
|
35
|
-
self.assertEqual(
|
35
|
+
self.assertEqual(hamming.distance("AGG", "AGA"), 1)
|
36
36
|
|
37
37
|
def test_same_nucleotides_in_different_positions(self):
|
38
|
-
self.assertEqual(
|
38
|
+
self.assertEqual(hamming.distance("TAG", "GAT"), 2)
|
39
39
|
|
40
40
|
def test_large_distance(self):
|
41
|
-
self.assertEqual(
|
41
|
+
self.assertEqual(hamming.distance("GATACA", "GCATAA"), 4)
|
42
42
|
|
43
43
|
def test_large_distance_in_off_by_one_strand(self):
|
44
|
-
self.assertEqual(
|
44
|
+
self.assertEqual(hamming.distance("GGACGGATTCTG", "AGGACGGATTCT"), 9)
|
45
45
|
|
46
46
|
def test_empty_strands(self):
|
47
|
-
self.assertEqual(
|
47
|
+
self.assertEqual(hamming.distance("", ""), 0)
|
48
48
|
|
49
49
|
def test_disallow_first_strand_longer(self):
|
50
50
|
with self.assertRaises(ValueError):
|
@@ -6,9 +6,8 @@ import hello_world
|
|
6
6
|
# test cases adapted from `x-common//canonical-data.json` @ version: 1.0.0
|
7
7
|
|
8
8
|
class HelloWorldTests(unittest.TestCase):
|
9
|
-
|
10
9
|
def test_hello(self):
|
11
|
-
self.assertEqual('Hello, World!'
|
10
|
+
self.assertEqual(hello_world.hello(), 'Hello, World!')
|
12
11
|
|
13
12
|
|
14
13
|
if __name__ == '__main__':
|
@@ -7,33 +7,32 @@ from hexadecimal import hexa
|
|
7
7
|
|
8
8
|
|
9
9
|
class HexadecimalTest(unittest.TestCase):
|
10
|
-
|
11
10
|
def test_valid_hexa1(self):
|
12
|
-
self.assertEqual(
|
11
|
+
self.assertEqual(hexa('1'), 1)
|
13
12
|
|
14
13
|
def test_valid_hexa2(self):
|
15
|
-
self.assertEqual(
|
14
|
+
self.assertEqual(hexa('c'), 12)
|
16
15
|
|
17
16
|
def test_valid_hexa3(self):
|
18
|
-
self.assertEqual(
|
17
|
+
self.assertEqual(hexa('10'), 16)
|
19
18
|
|
20
19
|
def test_valid_hexa4(self):
|
21
|
-
self.assertEqual(
|
20
|
+
self.assertEqual(hexa('af'), 175)
|
22
21
|
|
23
22
|
def test_valid_hexa5(self):
|
24
|
-
self.assertEqual(
|
23
|
+
self.assertEqual(hexa('100'), 256)
|
25
24
|
|
26
25
|
def test_valid_hexa6(self):
|
27
|
-
self.assertEqual(
|
26
|
+
self.assertEqual(hexa('19ACE'), 105166)
|
28
27
|
|
29
28
|
def test_valid_hexa7(self):
|
30
|
-
self.assertEqual(
|
29
|
+
self.assertEqual(hexa('000000'), 0)
|
31
30
|
|
32
31
|
def test_valid_hexa8(self):
|
33
|
-
self.assertEqual(
|
32
|
+
self.assertEqual(hexa('ffff00'), 16776960)
|
34
33
|
|
35
34
|
def test_valid_hexa9(self):
|
36
|
-
self.assertEqual(
|
35
|
+
self.assertEqual(hexa('00fff0'), 65520)
|
37
36
|
|
38
37
|
def test_invalid_hexa(self):
|
39
38
|
with self.assertRaises(ValueError):
|