trackler 2.2.1.74 → 2.2.1.75

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/fixtures/tracks/fruit/docs/something.md +0 -0
  3. data/lib/trackler/version.rb +1 -1
  4. data/problem-specifications/README.md +8 -4
  5. data/problem-specifications/exercises/acronym/canonical-data.json +19 -7
  6. data/problem-specifications/exercises/all-your-base/canonical-data.json +106 -64
  7. data/problem-specifications/exercises/allergies/canonical-data.json +37 -13
  8. data/tracks/c/config.json +176 -176
  9. data/tracks/clojure/config.json +17 -1
  10. data/tracks/clojure/exercises/isbn-verifier/README.md +43 -0
  11. data/tracks/clojure/exercises/isbn-verifier/project.clj +4 -0
  12. data/tracks/clojure/exercises/isbn-verifier/src/example.clj +17 -0
  13. data/tracks/clojure/exercises/isbn-verifier/src/isbn_verifier.clj +3 -0
  14. data/tracks/clojure/exercises/isbn-verifier/test/isbn_verifier_test.clj +42 -0
  15. data/tracks/clojure/exercises/proverb/README.md +15 -0
  16. data/tracks/clojure/exercises/proverb/project.clj +4 -0
  17. data/tracks/clojure/exercises/proverb/src/example.clj +15 -0
  18. data/tracks/clojure/exercises/proverb/src/proverb.clj +3 -0
  19. data/tracks/clojure/exercises/proverb/test/proverb_test.clj +14 -0
  20. data/tracks/common-lisp/docs/LEARNING.md +4 -3
  21. data/tracks/common-lisp/docs/RESOURCES.md +11 -0
  22. data/tracks/delphi/.gitignore +1 -0
  23. data/tracks/delphi/config.json +24 -0
  24. data/tracks/delphi/docs/INSTALLATION.md +1 -1
  25. data/tracks/delphi/exercises/isbn-verifier/ISBNVerifier.dpr +60 -0
  26. data/tracks/delphi/exercises/isbn-verifier/README.md +68 -0
  27. data/tracks/delphi/exercises/isbn-verifier/uISBNVerifierExample.pas +46 -0
  28. data/tracks/delphi/exercises/isbn-verifier/uTestISBNVerifier.pas +136 -0
  29. data/tracks/delphi/exercises/secret-handshake/README.md +56 -0
  30. data/tracks/delphi/exercises/secret-handshake/SecretHandshake.dpr +60 -0
  31. data/tracks/delphi/exercises/secret-handshake/uSecretHandshakeExample.pas +56 -0
  32. data/tracks/delphi/exercises/secret-handshake/uTestSecretHandshake.pas +215 -0
  33. data/tracks/ecmascript/docs/ABOUT.md +13 -9
  34. data/tracks/factor/exercises/two-fer/README.md +1 -1
  35. data/tracks/fsharp/docs/RESOURCES.md +1 -1
  36. data/tracks/fsharp/generators/{Input.fs → CanonicalData.fs} +5 -10
  37. data/tracks/fsharp/generators/Exercise.fs +11 -10
  38. data/tracks/fsharp/generators/{Output.fs → Formatting.fs} +2 -56
  39. data/tracks/fsharp/generators/Generators.fs +93 -93
  40. data/tracks/fsharp/generators/Generators.fsproj +9 -4
  41. data/tracks/fsharp/generators/Options.fs +1 -1
  42. data/tracks/fsharp/generators/Program.fs +3 -3
  43. data/tracks/fsharp/generators/Rendering.fs +57 -0
  44. data/tracks/go/exercises/all-your-base/.meta/gen.go +80 -0
  45. data/tracks/go/exercises/all-your-base/.meta/hints.md +13 -0
  46. data/tracks/go/exercises/all-your-base/README.md +16 -1
  47. data/tracks/go/exercises/all-your-base/all_your_base_test.go +12 -163
  48. data/tracks/go/exercises/all-your-base/cases_test.go +183 -0
  49. data/tracks/go/exercises/all-your-base/example.go +25 -29
  50. data/tracks/java/CONTRIBUTING.md +1 -1
  51. data/tracks/java/POLICIES.md +15 -1
  52. data/tracks/java/exercises/flatten-array/.meta/hints.md +58 -0
  53. data/tracks/java/exercises/flatten-array/README.md +62 -0
  54. data/tracks/java/exercises/hamming/src/main/java/Hamming.java +1 -1
  55. data/tracks/java/exercises/matrix/.meta/src/reference/java/Matrix.java +6 -6
  56. data/tracks/java/exercises/meetup/.meta/src/reference/java/Meetup.java +2 -2
  57. data/tracks/java/exercises/meetup/.meta/src/reference/java/MeetupSchedule.java +1 -1
  58. data/tracks/java/exercises/meetup/src/main/java/MeetupSchedule.java +1 -1
  59. data/tracks/java/exercises/pig-latin/.meta/hints.md +58 -0
  60. data/tracks/java/exercises/pig-latin/README.md +61 -0
  61. data/tracks/java/exercises/reverse-string/src/main/java/ReverseString.java +2 -2
  62. data/tracks/java/exercises/secret-handshake/README.md +1 -1
  63. data/tracks/javascript/.eslintignore +0 -3
  64. data/tracks/javascript/exercises/food-chain/example.js +50 -37
  65. data/tracks/javascript/exercises/octal/example.js +1 -1
  66. data/tracks/javascript/exercises/robot-name/robot-name.spec.js +7 -7
  67. data/tracks/javascript/package-lock.json +1846 -0
  68. data/tracks/python/docs/EXERCISE_README_INSERT.md +15 -0
  69. data/tracks/python/exercises/accumulate/README.md +15 -0
  70. data/tracks/python/exercises/acronym/README.md +15 -0
  71. data/tracks/python/exercises/all-your-base/README.md +15 -0
  72. data/tracks/python/exercises/all-your-base/all_your_base_test.py +19 -9
  73. data/tracks/python/exercises/allergies/README.md +15 -0
  74. data/tracks/python/exercises/alphametics/README.md +15 -0
  75. data/tracks/python/exercises/anagram/README.md +15 -0
  76. data/tracks/python/exercises/atbash-cipher/README.md +15 -0
  77. data/tracks/python/exercises/beer-song/README.md +16 -1
  78. data/tracks/python/exercises/binary-search-tree/README.md +16 -2
  79. data/tracks/python/exercises/binary-search/README.md +15 -0
  80. data/tracks/python/exercises/binary-search/binary_search_test.py +14 -4
  81. data/tracks/python/exercises/binary/README.md +15 -0
  82. data/tracks/python/exercises/binary/binary_test.py +14 -4
  83. data/tracks/python/exercises/bob/README.md +15 -0
  84. data/tracks/python/exercises/book-store/README.md +15 -0
  85. data/tracks/python/exercises/bracket-push/README.md +15 -0
  86. data/tracks/python/exercises/change/README.md +15 -0
  87. data/tracks/python/exercises/circular-buffer/README.md +15 -0
  88. data/tracks/python/exercises/circular-buffer/circular_buffer_test.py +15 -5
  89. data/tracks/python/exercises/circular-buffer/example.py +2 -2
  90. data/tracks/python/exercises/clock/README.md +15 -0
  91. data/tracks/python/exercises/collatz-conjecture/.meta/hints.md +1 -1
  92. data/tracks/python/exercises/collatz-conjecture/README.md +15 -0
  93. data/tracks/python/exercises/complex-numbers/README.md +15 -0
  94. data/tracks/python/exercises/connect/README.md +18 -3
  95. data/tracks/python/exercises/crypto-square/README.md +15 -0
  96. data/tracks/python/exercises/diamond/README.md +15 -0
  97. data/tracks/python/exercises/difference-of-squares/README.md +15 -0
  98. data/tracks/python/exercises/diffie-hellman/README.md +14 -0
  99. data/tracks/python/exercises/dominoes/README.md +16 -1
  100. data/tracks/python/exercises/error-handling/README.md +17 -0
  101. data/tracks/python/exercises/error-handling/error_handling_test.py +13 -3
  102. data/tracks/python/exercises/error-handling/example.py +1 -1
  103. data/tracks/python/exercises/etl/README.md +16 -1
  104. data/tracks/python/exercises/flatten-array/README.md +15 -0
  105. data/tracks/python/exercises/food-chain/README.md +15 -0
  106. data/tracks/python/exercises/forth/README.md +15 -0
  107. data/tracks/python/exercises/forth/example.py +7 -9
  108. data/tracks/python/exercises/forth/forth_test.py +107 -17
  109. data/tracks/python/exercises/gigasecond/README.md +15 -0
  110. data/tracks/python/exercises/go-counting/README.md +21 -3
  111. data/tracks/python/exercises/grade-school/README.md +15 -0
  112. data/tracks/python/exercises/grains/README.md +15 -0
  113. data/tracks/python/exercises/grains/grains_test.py +16 -6
  114. data/tracks/python/exercises/grep/README.md +15 -0
  115. data/tracks/python/exercises/hamming/README.md +15 -0
  116. data/tracks/python/exercises/hamming/hamming_test.py +12 -2
  117. data/tracks/python/exercises/hello-world/README.md +15 -0
  118. data/tracks/python/exercises/hexadecimal/README.md +15 -0
  119. data/tracks/python/exercises/hexadecimal/hexadecimal_test.py +11 -1
  120. data/tracks/python/exercises/house/README.md +16 -1
  121. data/tracks/python/exercises/isogram/README.md +15 -0
  122. data/tracks/python/exercises/kindergarten-garden/README.md +18 -3
  123. data/tracks/python/exercises/largest-series-product/README.md +15 -0
  124. data/tracks/python/exercises/largest-series-product/largest_series_product_test.py +14 -4
  125. data/tracks/python/exercises/leap/README.md +15 -0
  126. data/tracks/python/exercises/linked-list/README.md +15 -0
  127. data/tracks/python/exercises/list-ops/README.md +15 -0
  128. data/tracks/python/exercises/luhn/README.md +15 -0
  129. data/tracks/python/exercises/markdown/README.md +18 -0
  130. data/tracks/python/exercises/matrix/README.md +15 -0
  131. data/tracks/python/exercises/meetup/README.md +31 -12
  132. data/tracks/python/exercises/meetup/meetup_test.py +11 -1
  133. data/tracks/python/exercises/minesweeper/README.md +15 -0
  134. data/tracks/python/exercises/minesweeper/minesweeper_test.py +12 -2
  135. data/tracks/python/exercises/nth-prime/README.md +15 -0
  136. data/tracks/python/exercises/nth-prime/nth_prime_test.py +11 -1
  137. data/tracks/python/exercises/nucleotide-count/README.md +17 -2
  138. data/tracks/python/exercises/nucleotide-count/nucleotide_count_test.py +11 -1
  139. data/tracks/python/exercises/ocr-numbers/README.md +16 -1
  140. data/tracks/python/exercises/ocr-numbers/ocr_numbers_test.py +12 -2
  141. data/tracks/python/exercises/octal/README.md +15 -0
  142. data/tracks/python/exercises/octal/octal_test.py +16 -3
  143. data/tracks/python/exercises/palindrome-products/README.md +16 -1
  144. data/tracks/python/exercises/pangram/README.md +15 -0
  145. data/tracks/python/exercises/pascals-triangle/README.md +16 -1
  146. data/tracks/python/exercises/perfect-numbers/README.md +15 -0
  147. data/tracks/python/exercises/perfect-numbers/perfect_numbers_test.py +13 -3
  148. data/tracks/python/exercises/phone-number/README.md +16 -2
  149. data/tracks/python/exercises/phone-number/example.py +1 -1
  150. data/tracks/python/exercises/phone-number/phone_number_test.py +17 -7
  151. data/tracks/python/exercises/pig-latin/README.md +15 -0
  152. data/tracks/python/exercises/point-mutations/README.md +15 -0
  153. data/tracks/python/exercises/poker/README.md +15 -0
  154. data/tracks/python/exercises/pov/README.md +20 -2
  155. data/tracks/python/exercises/pov/example.py +2 -2
  156. data/tracks/python/exercises/pov/pov_test.py +15 -5
  157. data/tracks/python/exercises/prime-factors/README.md +15 -0
  158. data/tracks/python/exercises/protein-translation/README.md +15 -0
  159. data/tracks/python/exercises/protein-translation/protein_translation_test.py +10 -0
  160. data/tracks/python/exercises/proverb/README.md +14 -0
  161. data/tracks/python/exercises/pythagorean-triplet/README.md +15 -0
  162. data/tracks/python/exercises/pythagorean-triplet/pythagorean_triplet_test.py +11 -1
  163. data/tracks/python/exercises/queen-attack/README.md +15 -0
  164. data/tracks/python/exercises/queen-attack/queen_attack_test.py +17 -7
  165. data/tracks/python/exercises/rail-fence-cipher/README.md +15 -0
  166. data/tracks/python/exercises/raindrops/README.md +15 -0
  167. data/tracks/python/exercises/react/README.md +15 -1
  168. data/tracks/python/exercises/rectangles/README.md +24 -9
  169. data/tracks/python/exercises/rna-transcription/.meta/hints.md +1 -0
  170. data/tracks/python/exercises/rna-transcription/README.md +18 -5
  171. data/tracks/python/exercises/rna-transcription/rna_transcription_test.py +13 -3
  172. data/tracks/python/exercises/robot-name/README.md +15 -0
  173. data/tracks/python/exercises/robot-simulator/README.md +15 -0
  174. data/tracks/python/exercises/roman-numerals/README.md +15 -0
  175. data/tracks/python/exercises/rotational-cipher/README.md +15 -0
  176. data/tracks/python/exercises/run-length-encoding/README.md +15 -0
  177. data/tracks/python/exercises/saddle-points/README.md +15 -0
  178. data/tracks/python/exercises/saddle-points/saddle_points_test.py +11 -1
  179. data/tracks/python/exercises/say/README.md +15 -0
  180. data/tracks/python/exercises/say/say_test.py +12 -2
  181. data/tracks/python/exercises/scale-generator/README.md +15 -0
  182. data/tracks/python/exercises/scale-generator/example.py +3 -3
  183. data/tracks/python/exercises/scale-generator/scale_generator_test.py +11 -1
  184. data/tracks/python/exercises/scrabble-score/README.md +15 -0
  185. data/tracks/python/exercises/secret-handshake/README.md +16 -1
  186. data/tracks/python/exercises/series/README.md +15 -0
  187. data/tracks/python/exercises/series/series_test.py +12 -2
  188. data/tracks/python/exercises/sieve/README.md +15 -0
  189. data/tracks/python/exercises/simple-cipher/.meta/hints.md +6 -6
  190. data/tracks/python/exercises/simple-cipher/README.md +17 -1
  191. data/tracks/python/exercises/simple-cipher/simple_cipher_test.py +12 -2
  192. data/tracks/python/exercises/simple-linked-list/{hints.md → .meta/hints.md} +10 -10
  193. data/tracks/python/exercises/simple-linked-list/README.md +16 -0
  194. data/tracks/python/exercises/simple-linked-list/example.py +2 -2
  195. data/tracks/python/exercises/simple-linked-list/simple_linked_list_test.py +13 -3
  196. data/tracks/python/exercises/space-age/README.md +15 -0
  197. data/tracks/python/exercises/strain/README.md +16 -3
  198. data/tracks/python/exercises/sublist/README.md +15 -0
  199. data/tracks/python/exercises/sum-of-multiples/README.md +18 -3
  200. data/tracks/python/exercises/tournament/README.md +15 -0
  201. data/tracks/python/exercises/transpose/README.md +15 -0
  202. data/tracks/python/exercises/tree-building/README.md +30 -0
  203. data/tracks/python/exercises/tree-building/example.py +3 -5
  204. data/tracks/python/exercises/tree-building/tree_building_test.py +16 -6
  205. data/tracks/python/exercises/triangle/README.md +15 -0
  206. data/tracks/python/exercises/triangle/example.py +1 -1
  207. data/tracks/python/exercises/triangle/triangle_test.py +15 -5
  208. data/tracks/python/exercises/trinary/README.md +15 -0
  209. data/tracks/python/exercises/twelve-days/README.md +15 -0
  210. data/tracks/python/exercises/two-bucket/README.md +22 -7
  211. data/tracks/python/exercises/two-fer/README.md +16 -0
  212. data/tracks/python/exercises/variable-length-quantity/README.md +15 -0
  213. data/tracks/python/exercises/variable-length-quantity/variable_length_quantity_test.py +12 -2
  214. data/tracks/python/exercises/word-count/README.md +15 -0
  215. data/tracks/python/exercises/word-search/README.md +15 -0
  216. data/tracks/python/exercises/wordy/README.md +15 -0
  217. data/tracks/python/exercises/wordy/wordy_test.py +14 -4
  218. data/tracks/python/exercises/zebra-puzzle/README.md +15 -0
  219. data/tracks/python/exercises/zipper/README.md +16 -3
  220. data/tracks/rust/config.json +11 -0
  221. data/tracks/rust/exercises/saddle-points/.gitignore +8 -0
  222. data/tracks/rust/exercises/saddle-points/Cargo.toml +5 -0
  223. data/tracks/rust/exercises/saddle-points/README.md +66 -0
  224. data/tracks/rust/exercises/saddle-points/example.rs +24 -0
  225. data/tracks/rust/exercises/saddle-points/src/lib.rs +3 -0
  226. data/tracks/rust/exercises/saddle-points/tests/saddle-points.rs +60 -0
  227. metadata +38 -5
@@ -38,9 +38,19 @@ class SaddlePointTest(unittest.TestCase):
38
38
 
39
39
  def test_irregular_matrix(self):
40
40
  inp = [[3, 2, 1], [0, 1], [2, 1, 0]]
41
- with self.assertRaises(ValueError):
41
+ with self.assertRaisesWithMessage(ValueError):
42
42
  saddle_points(inp)
43
43
 
44
+ # Utility functions
45
+ def setUp(self):
46
+ try:
47
+ self.assertRaisesRegex = self.assertRaisesRegexp
48
+ except AttributeError:
49
+ pass
50
+
51
+ def assertRaisesWithMessage(self, exception):
52
+ return self.assertRaisesRegex(exception, r".+")
53
+
44
54
 
45
55
  if __name__ == '__main__':
46
56
  unittest.main()
@@ -62,6 +62,21 @@ Use _and_ (correctly) when spelling out the number in English:
62
62
  - 1002 becomes "one thousand and two".
63
63
  - 1323 becomes "one thousand three hundred and twenty-three".
64
64
 
65
+ ## Exception messages
66
+
67
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
68
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
69
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
70
+ a message.
71
+
72
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
73
+ `raise Exception`, you shold write:
74
+
75
+ ```python
76
+ raise Exception("Meaningful message indicating the source of the error")
77
+ ```
78
+
79
+
65
80
  ## Submitting Exercises
66
81
 
67
82
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -64,13 +64,23 @@ class SayTest(unittest.TestCase):
64
64
  "one hundred and twenty-three"))
65
65
 
66
66
  def test_number_to_large(self):
67
- with self.assertRaises(ValueError):
67
+ with self.assertRaisesWithMessage(ValueError):
68
68
  say(1e12)
69
69
 
70
70
  def test_number_negative(self):
71
- with self.assertRaises(ValueError):
71
+ with self.assertRaisesWithMessage(ValueError):
72
72
  say(-1)
73
73
 
74
+ # Utility functions
75
+ def setUp(self):
76
+ try:
77
+ self.assertRaisesRegex = self.assertRaisesRegexp
78
+ except AttributeError:
79
+ pass
80
+
81
+ def assertRaisesWithMessage(self, exception):
82
+ return self.assertRaisesRegex(exception, r".+")
83
+
74
84
 
75
85
  if __name__ == '__main__':
76
86
  unittest.main()
@@ -55,6 +55,21 @@ Here is a table of pitches with the names of their interval distance from the to
55
55
  | | | Dim 3rd | Aug 2nd | Dim 4th | | Aug 4th | Dim 5th | Aug 5th | Dim 7th | Aug 6th | Dim 8ve | |
56
56
  | | | | | | | Dim 5th | | | | | | |
57
57
 
58
+ ## Exception messages
59
+
60
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
61
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
62
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
63
+ a message.
64
+
65
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
66
+ `raise Exception`, you shold write:
67
+
68
+ ```python
69
+ raise Exception("Meaningful message indicating the source of the error")
70
+ ```
71
+
72
+
58
73
  ## Submitting Exercises
59
74
 
60
75
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -13,8 +13,8 @@ class Scale(object):
13
13
  self.name = self.tonic + ' ' + scale_name
14
14
  self.pattern = pattern
15
15
  self.chromatic_scale = (self.FLAT_CHROMATIC_SCALE
16
- if tonic in self.FLAT_KEYS else
17
- self.CHROMATIC_SCALE)
16
+ if tonic in self.FLAT_KEYS
17
+ else self.CHROMATIC_SCALE)
18
18
  self.pitches = self._assign_pitches()
19
19
 
20
20
  def _assign_pitches(self):
@@ -27,7 +27,7 @@ class Scale(object):
27
27
  pitches.append(scale[last_index])
28
28
  last_index += self.ASCENDING_INTERVALS.index(interval) + 1
29
29
  if pitches[0] != scale[last_index % len(scale)]:
30
- raise ValueError()
30
+ raise ValueError("Interval is broken")
31
31
  return pitches
32
32
 
33
33
  def _reorder_chromatic_scale(self):
@@ -116,9 +116,19 @@ class ScaleGeneratorTest(unittest.TestCase):
116
116
  self.assertEqual(expected, actual)
117
117
 
118
118
  def test_brokeninterval(self):
119
- with self.assertRaises(ValueError):
119
+ with self.assertRaisesWithMessage(ValueError):
120
120
  Scale('G', 'enigmatic', 'mAMMMmM')
121
121
 
122
+ # Utility functions
123
+ def setUp(self):
124
+ try:
125
+ self.assertRaisesRegex = self.assertRaisesRegexp
126
+ except AttributeError:
127
+ pass
128
+
129
+ def assertRaisesWithMessage(self, exception):
130
+ return self.assertRaisesRegex(exception, r".+")
131
+
122
132
 
123
133
  if __name__ == '__main__':
124
134
  unittest.main()
@@ -39,6 +39,21 @@ And to total:
39
39
  - You can play a double or a triple letter.
40
40
  - You can play a double or a triple word.
41
41
 
42
+ ## Exception messages
43
+
44
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
45
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
46
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
47
+ a message.
48
+
49
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
50
+ `raise Exception`, you shold write:
51
+
52
+ ```python
53
+ raise Exception("Meaningful message indicating the source of the error")
54
+ ```
55
+
56
+
42
57
  ## Submitting Exercises
43
58
 
44
59
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -28,6 +28,21 @@ Given the input 19, the function would return the array
28
28
  Notice that the addition of 16 (10000 in binary)
29
29
  has caused the array to be reversed.
30
30
 
31
+ ## Exception messages
32
+
33
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
34
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
35
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
36
+ a message.
37
+
38
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
39
+ `raise Exception`, you shold write:
40
+
41
+ ```python
42
+ raise Exception("Meaningful message indicating the source of the error")
43
+ ```
44
+
45
+
31
46
  ## Submitting Exercises
32
47
 
33
48
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -39,7 +54,7 @@ please see the [help page](http://exercism.io/languages/python).
39
54
 
40
55
  ## Source
41
56
 
42
- Bert, in Mary Poppins [http://www.imdb.com/character/ch0011238/quotes](http://www.imdb.com/character/ch0011238/quotes)
57
+ Bert, in Mary Poppins http://www.imdb.com/title/tt0058331/quotes/qt0437047
43
58
 
44
59
  ## Submitting Incomplete Solutions
45
60
  It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -20,6 +20,21 @@ whatever you get.
20
20
  Note that these series are only required to occupy *adjacent positions*
21
21
  in the input; the digits need not be *numerically consecutive*.
22
22
 
23
+ ## Exception messages
24
+
25
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
26
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
27
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
28
+ a message.
29
+
30
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
31
+ `raise Exception`, you shold write:
32
+
33
+ ```python
34
+ raise Exception("Meaningful message indicating the source of the error")
35
+ ```
36
+
37
+
23
38
  ## Submitting Exercises
24
39
 
25
40
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -37,13 +37,23 @@ class SeriesTest(unittest.TestCase):
37
37
  [[0, 1, 2, 3, 4]], )
38
38
 
39
39
  def test_overly_long_slice(self):
40
- with self.assertRaises(ValueError):
40
+ with self.assertRaisesWithMessage(ValueError):
41
41
  slices("012", 4)
42
42
 
43
43
  def test_overly_short_slice(self):
44
- with self.assertRaises(ValueError):
44
+ with self.assertRaisesWithMessage(ValueError):
45
45
  slices("01234", 0)
46
46
 
47
+ # Utility functions
48
+ def setUp(self):
49
+ try:
50
+ self.assertRaisesRegex = self.assertRaisesRegexp
51
+ except AttributeError:
52
+ pass
53
+
54
+ def assertRaisesWithMessage(self, exception):
55
+ return self.assertRaisesRegex(exception, r".+")
56
+
47
57
 
48
58
  if __name__ == '__main__':
49
59
  unittest.main()
@@ -27,6 +27,21 @@ Notice that this is a very specific algorithm, and the tests don't check
27
27
  that you've implemented the algorithm, only that you've come up with the
28
28
  correct list of primes.
29
29
 
30
+ ## Exception messages
31
+
32
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
33
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
34
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
35
+ a message.
36
+
37
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
38
+ `raise Exception`, you shold write:
39
+
40
+ ```python
41
+ raise Exception("Meaningful message indicating the source of the error")
42
+ ```
43
+
44
+
30
45
  ## Submitting Exercises
31
46
 
32
47
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -3,14 +3,14 @@
3
3
  Python, as of version 3.6, includes two different random modules.
4
4
 
5
5
  The module called `random` is pseudo-random, meaning it does not generate
6
- true randomness, but follows an algorithm that simulates randomness.
7
- Since random numbers are generated through a known algorithm, they are not truly random.
6
+ true randomness, but follows an algorithm that simulates randomness.
7
+ Since random numbers are generated through a known algorithm, they are not truly random.
8
8
 
9
- The `random` module is not correctly suited for cryptography and should not be used,
10
- precisely because it is pseudo-random.
9
+ The `random` module is not correctly suited for cryptography and should not be used,
10
+ precisely because it is pseudo-random.
11
11
 
12
12
  For this reason, in version 3.6, Python introduced the `secrets` module, which generates
13
- cryptographically strong random numbers that provide the greater security required for cryptography.
13
+ cryptographically strong random numbers that provide the greater security required for cryptography.
14
14
 
15
- Since this is only an exercise, `random` is fine to use, but note that **it would be
15
+ Since this is only an exercise, `random` is fine to use, but note that **it would be
16
16
  very insecure if actually used for cryptography.**
@@ -65,7 +65,7 @@ If someone doesn't submit a key at all, generate a truly random key of
65
65
  at least 100 characters in length, accessible via Cipher#key (the #
66
66
  syntax means instance variable)
67
67
 
68
- If the key submitted has capital letters or numbers, throw a
68
+ If the key submitted has capital letters or numbers, raise a
69
69
  ValueError with a message to that effect.
70
70
 
71
71
  ## Extensions
@@ -100,6 +100,22 @@ cryptographically strong random numbers that provide the greater security requir
100
100
  Since this is only an exercise, `random` is fine to use, but note that **it would be
101
101
  very insecure if actually used for cryptography.**
102
102
 
103
+
104
+ ## Exception messages
105
+
106
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
107
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
108
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
109
+ a message.
110
+
111
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
112
+ `raise Exception`, you shold write:
113
+
114
+ ```python
115
+ raise Exception("Meaningful message indicating the source of the error")
116
+ ```
117
+
118
+
103
119
  ## Submitting Exercises
104
120
 
105
121
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -68,11 +68,21 @@ class CipherTest(unittest.TestCase):
68
68
  'All items in the key must be chars and lowercase!')
69
69
 
70
70
  def test_cipher_wrong_key(self):
71
- with self.assertRaises(ValueError):
71
+ with self.assertRaisesWithMessage(ValueError):
72
72
  Cipher('a1cde')
73
- with self.assertRaises(ValueError):
73
+ with self.assertRaisesWithMessage(ValueError):
74
74
  Cipher('aBcde')
75
75
 
76
+ # Utility functions
77
+ def setUp(self):
78
+ try:
79
+ self.assertRaisesRegex = self.assertRaisesRegexp
80
+ except AttributeError:
81
+ pass
82
+
83
+ def assertRaisesWithMessage(self, exception):
84
+ return self.assertRaisesRegex(exception, r".+")
85
+
76
86
 
77
87
  if __name__ == '__main__':
78
88
  unittest.main()
@@ -1,10 +1,10 @@
1
- ## Hints
2
-
3
- To support `list()`, see [implementing an iterator for a class.](https://docs.python.org/3/tutorial/classes.html#iterators)
4
-
5
- Additionally, note that Python2's `next()` has been replaced by `__next__()` in Python3. For dual compatibility, `next()` can be implemented as:
6
-
7
- ```Python
8
- def next(self):
9
- return self.__next__()
10
- ```
1
+ ## Hints
2
+
3
+ To support `list()`, see [implementing an iterator for a class.](https://docs.python.org/3/tutorial/classes.html#iterators)
4
+
5
+ Additionally, note that Python2's `next()` has been replaced by `__next__()` in Python3. For dual compatibility, `next()` can be implemented as:
6
+
7
+ ```Python
8
+ def next(self):
9
+ return self.__next__()
10
+ ```
@@ -32,6 +32,22 @@ def next(self):
32
32
  return self.__next__()
33
33
  ```
34
34
 
35
+
36
+ ## Exception messages
37
+
38
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
39
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
40
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
41
+ a message.
42
+
43
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
44
+ `raise Exception`, you shold write:
45
+
46
+ ```python
47
+ raise Exception("Meaningful message indicating the source of the error")
48
+ ```
49
+
50
+
35
51
  ## Submitting Exercises
36
52
 
37
53
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
@@ -42,7 +42,7 @@ class LinkedList(object):
42
42
 
43
43
  def head(self):
44
44
  if self._head is None:
45
- raise EmptyListException()
45
+ raise EmptyListException("The list is empty")
46
46
  return self._head
47
47
 
48
48
  def push(self, value):
@@ -53,7 +53,7 @@ class LinkedList(object):
53
53
 
54
54
  def pop(self):
55
55
  if self._head is None:
56
- raise EmptyListException()
56
+ raise EmptyListException("The list is empty")
57
57
  self._len -= 1
58
58
  ret = self._head.value()
59
59
  self._head = self._head.next()
@@ -20,7 +20,7 @@ class LinkedListTest(unittest.TestCase):
20
20
 
21
21
  def test_error_on_empty_list_head(self):
22
22
  sut = LinkedList()
23
- with self.assertRaises(EmptyListException):
23
+ with self.assertRaisesWithMessage(EmptyListException):
24
24
  sut.head()
25
25
 
26
26
  def test_singleton_list_has_head(self):
@@ -51,12 +51,12 @@ class LinkedListTest(unittest.TestCase):
51
51
  def test_pop_from_singleton_list_removes_head(self):
52
52
  sut = LinkedList([1])
53
53
  self.assertEqual(sut.pop(), 1)
54
- with self.assertRaises(EmptyListException):
54
+ with self.assertRaisesWithMessage(EmptyListException):
55
55
  sut.head()
56
56
 
57
57
  def test_error_on_empty_list_pop(self):
58
58
  sut = LinkedList()
59
- with self.assertRaises(EmptyListException):
59
+ with self.assertRaisesWithMessage(EmptyListException):
60
60
  sut.pop()
61
61
 
62
62
  def test_push_and_pop(self):
@@ -107,6 +107,16 @@ class LinkedListTest(unittest.TestCase):
107
107
  sut = LinkedList([1, 2, 3])
108
108
  self.assertEqual(list(sut.reversed()), [1, 2, 3])
109
109
 
110
+ # Utility functions
111
+ def setUp(self):
112
+ try:
113
+ self.assertRaisesRegex = self.assertRaisesRegexp
114
+ except AttributeError:
115
+ pass
116
+
117
+ def assertRaisesWithMessage(self, exception):
118
+ return self.assertRaisesRegex(exception, r".+")
119
+
110
120
 
111
121
  if __name__ == '__main__':
112
122
  unittest.main()
@@ -17,6 +17,21 @@ be able to say that they're 31.69 Earth-years old.
17
17
  If you're wondering why Pluto didn't make the cut, go watch [this
18
18
  youtube video](http://www.youtube.com/watch?v=Z_2gbGXzFbs).
19
19
 
20
+ ## Exception messages
21
+
22
+ Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
23
+ indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
24
+ every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
25
+ a message.
26
+
27
+ To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
28
+ `raise Exception`, you shold write:
29
+
30
+ ```python
31
+ raise Exception("Meaningful message indicating the source of the error")
32
+ ```
33
+
34
+
20
35
  ## Submitting Exercises
21
36
 
22
37
  Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.