Skip to content

[WIP] Full-scale test update #1262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 85 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
709b674
hello-world: update test to v1.1.0
mrcfps Feb 14, 2018
dca90da
leap: update test to v1.3.0
mrcfps Feb 14, 2018
0617557
reverse-string: update test to v1.1.0
mrcfps Feb 14, 2018
42eacc5
pangram: update tests to v1.4.0
mrcfps Feb 14, 2018
4475eef
rna-transcription: update tests to v1.2.0
mrcfps Feb 14, 2018
1fa3ba0
hamming: update tests to v2.1.0
mrcfps Feb 14, 2018
81119bf
word-count: update tests to v1.2.0
mrcfps Feb 14, 2018
105987c
gigasecond: update tests to v1.1.0
mrcfps Feb 14, 2018
634a7c0
run-length-encoding: update tests to v1.1.0
mrcfps Feb 14, 2018
0873424
meetup: update tests to v1.1.0
mrcfps Feb 14, 2018
7adc971
rotational-cipher: update tests to v1.2.0
mrcfps Feb 14, 2018
8490fc2
difference-of-squares: update tests to v1.2.0
mrcfps Feb 14, 2018
dbf4c25
anagram: update tests to v1.2.0
mrcfps Feb 14, 2018
c150717
allergies: update tests to v1.1.0
mrcfps Feb 14, 2018
a1617c0
robot-simulator: update tests to v2.2.0
mrcfps Feb 14, 2018
c743097
sieve: update tests to v1.1.0
mrcfps Feb 14, 2018
b784344
atbash-cipher: update tests to v1.1.0
mrcfps Feb 14, 2018
84028a0
sum-of-multiples: update tests to v1.2.0
mrcfps Feb 14, 2018
ff12aa1
acronym: update tests to v1.3.0
mrcfps Feb 14, 2018
d63fafa
say: update tests to v1.1.0
mrcfps Feb 14, 2018
4d87c0f
largest-series-product: update tests to v1.1.0
mrcfps Feb 14, 2018
c36ced9
kindergarten-garden: update tests to v1.1.0
mrcfps Feb 14, 2018
ef861f7
flatten-array: update tests to v1.2.0
mrcfps Feb 14, 2018
ce7ade8
roman-numerals: update tests to v1.2.0
mrcfps Feb 14, 2018
978a597
space-age: update tests to v1.1.0
mrcfps Feb 14, 2018
1ff3417
luhn: update tests to v1.1.0
mrcfps Feb 14, 2018
7f1de0c
prime-factors: update tests to v1.1.0
mrcfps Feb 14, 2018
e3ada3f
pig-latin: update tests to v1.2.0
mrcfps Feb 14, 2018
30b1bfe
scrabble-score: update tests to v1.1.0
mrcfps Feb 14, 2018
44ffd83
crypto-square: update tests to v3.2.0
mrcfps Feb 14, 2018
d848bd2
sublist: update tests to v1.1.0
mrcfps Feb 14, 2018
47a5072
circular-buffer: update tests to v1.1.0
mrcfps Feb 14, 2018
5fbffe6
matrix: update tests to v1.0.0
mrcfps Feb 14, 2018
3299896
rail-fence-cipher: update tests to v1.1.0
mrcfps Feb 14, 2018
4407909
nth-prime: update tests to v2.1.0
mrcfps Feb 14, 2018
8f3a224
saddle-points: update tests to v1.1.0
mrcfps Feb 14, 2018
31ede3a
perfect-numbers: update tests to v1.1.0
mrcfps Feb 14, 2018
c3ca07b
secret-handshake: update tests to v1.2.0
mrcfps Feb 14, 2018
65defaa
twelve-days: update tests to v1.1.0
mrcfps Feb 14, 2018
7b8600d
palindrome-products: update tests to v1.1.0
mrcfps Feb 14, 2018
ee36a9f
bracket-push: update tests to v1.2.0
mrcfps Feb 14, 2018
46e6855
minesweeper: update tests to v1.1.0
mrcfps Feb 14, 2018
b645428
queen-attack: update tests to v2.1.0
mrcfps Feb 14, 2018
b5512aa
wordy: update tests to v1.1.0
mrcfps Feb 14, 2018
3e1e396
phone-number: update tests to v1.4.0
mrcfps Feb 14, 2018
064446c
ocr-numbers: update tests to v1.1.0
mrcfps Feb 14, 2018
5d80d7f
poker: update tests to v1.1.0
mrcfps Feb 14, 2018
b83cb35
zebra-puzzle: update tests to v1.1.0
mrcfps Feb 14, 2018
bdec418
rectangles: update tests to v1.1.0
mrcfps Feb 14, 2018
ce52b7c
binary-search: update tests to v1.1.0
mrcfps Feb 14, 2018
767fe95
list-ops: update tests to v2.2.0
mrcfps Feb 14, 2018
0959ddc
book-store: update tests to v1.3.0
mrcfps Feb 14, 2018
d7a2e12
diamond: update tests to v1.1.0
mrcfps Feb 14, 2018
2662291
variable-length-quantity: update tests to v1.1.0
mrcfps Feb 14, 2018
c098f27
bowling: update tests to v1.1.0
mrcfps Feb 14, 2018
dfdb340
word-search: update tests to v1.2.0
mrcfps Feb 14, 2018
90350dc
alphametics: update tests to v1.2.0
mrcfps Feb 14, 2018
e32c767
tournament: update tests to v1.4.0
mrcfps Feb 14, 2018
2901e66
protein-translation: update tests to v1.1.0
mrcfps Feb 14, 2018
72edb64
change: update tests to v1.2.0
mrcfps Feb 14, 2018
a475b77
two-fer: update tests to v1.2.0
mrcfps Feb 14, 2018
ecf507f
collatz-conjecture: update tests to v1.2.0
mrcfps Feb 14, 2018
c971ae0
complex-numbers: update tests to v1.3.0
mrcfps Feb 14, 2018
4168586
two-bucket: update tests to v1.4.0
mrcfps Feb 14, 2018
7c32568
markdown: update tests to v1.2.0
mrcfps Feb 14, 2018
3aeb634
forth: update tests to v1.5.0
mrcfps Feb 14, 2018
0fb8282
zipper: update tests to v1.1.0
mrcfps Feb 14, 2018
b5c4da0
dominoes: update tests to v2.1.0
mrcfps Feb 14, 2018
ec407ee
pov: update tests to v1.2.0
mrcfps Feb 14, 2018
e75b392
custom-set: update tests to v1.3.0
mrcfps Feb 14, 2018
da8fdb9
react: update tests to v1.1.0
mrcfps Feb 14, 2018
d019c8b
luhn: recover encoding declaration in test file
mrcfps Feb 14, 2018
a97dd2f
book-store: fix test assertions
mrcfps Feb 14, 2018
e4fde97
book-store: modify example to pass tests
mrcfps Feb 14, 2018
ae8c8fc
luhn: fix encoding problem
mrcfps Feb 14, 2018
f721036
Merge branch 'master' into full-scale-test-update
mrcfps Feb 14, 2018
48ba784
house: update tests to v2.1.0
mrcfps Feb 14, 2018
c19f3a5
house: modify example to pass tests
mrcfps Feb 14, 2018
ee73ae3
house: fix style(E302) in example
mrcfps Feb 15, 2018
813b021
all-your-base: update tests to v2.3.0
mrcfps Feb 15, 2018
ac95268
all-your-base: fit input param to canonical data in stub file
mrcfps Feb 15, 2018
7e4f8ff
clock: update tests to v2.2.1
mrcfps Feb 15, 2018
f69d0c4
clock: add necessary methods to clock in stub
mrcfps Feb 15, 2018
bee09f4
scale-generator: update tests to v1.0.0
mrcfps Feb 15, 2018
cb03f6b
scale-generator: update stub file
mrcfps Feb 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions exercises/acronym/acronym_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from acronym import abbreviate


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.3.0

class AcronymTest(unittest.TestCase):
def test_basic(self):
Expand All @@ -16,12 +16,9 @@ def test_punctuation(self):
self.assertEqual(abbreviate('First In, First Out'), 'FIFO')

def test_all_caps_words(self):
self.assertEqual(abbreviate('PHP: Hypertext Preprocessor'), 'PHP')

def test_non_acronym_all_caps_word(self):
self.assertEqual(abbreviate('GNU Image Manipulation Program'), 'GIMP')

def test_hyphenated(self):
def test_punctuation_without_whitespace(self):
self.assertEqual(
abbreviate('Complementary metal-oxide semiconductor'), 'CMOS')

Expand Down
2 changes: 1 addition & 1 deletion exercises/all-your-base/all_your_base.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def rebase(from_base, digits, to_base):
def rebase(input_base, digits, output_base):
pass
16 changes: 8 additions & 8 deletions exercises/all-your-base/all_your_base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from all_your_base import rebase


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0
# Tests adapted from `problem-specifications//canonical-data.json` @ v2.3.0

class AllYourBaseTests(unittest.TestCase):

Expand Down Expand Up @@ -43,15 +43,15 @@ def test_multiple_zeroes(self):
def test_leading_zeros(self):
self.assertEqual(rebase(7, [0, 6, 0], 10), [4, 2])

def test_first_base_is_one(self):
def test_input_base_is_one(self):
with self.assertRaisesWithMessage(ValueError):
rebase(1, [], 10)
rebase(1, [0], 10)

def test_first_base_is_zero(self):
def test_input_base_is_zero(self):
with self.assertRaisesWithMessage(ValueError):
rebase(0, [], 10)

def test_first_base_is_negative(self):
def test_input_base_is_negative(self):
with self.assertRaisesWithMessage(ValueError):
rebase(-2, [1], 10)

Expand All @@ -63,15 +63,15 @@ def test_invalid_positive_digit(self):
with self.assertRaisesWithMessage(ValueError):
rebase(2, [1, 2, 1, 0, 1, 0], 10)

def test_second_base_is_one(self):
def test_output_base_is_one(self):
with self.assertRaisesWithMessage(ValueError):
rebase(2, [1, 0, 1, 0, 1, 0], 1)

def test_second_base_is_zero(self):
def test_output_base_is_zero(self):
with self.assertRaisesWithMessage(ValueError):
rebase(10, [7], 0)

def test_second_base_is_negative(self):
def test_output_base_is_negative(self):
with self.assertRaisesWithMessage(ValueError):
rebase(2, [1], -7)

Expand Down
2 changes: 1 addition & 1 deletion exercises/allergies/allergies_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
unittest.TestCase.assertCountEqual = unittest.TestCase.assertItemsEqual


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.0
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0

class AllergiesTests(unittest.TestCase):
def test_no_allergies_means_not_allergic(self):
Expand Down
41 changes: 41 additions & 0 deletions exercises/alphametics/alphametics_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,47 @@ def test_puzzle_with_10_letters(self):
"S": 6,
"T": 9})

def test_puzzle_with_10_letters_and_41_addends(self):
self.assertEqual(
solve(
"THIS + A + FIRE + THEREFORE + FOR + ALL + HISTORIES + I"
" + TELL + A + TALE + THAT + FALSIFIES + ITS + TITLE + TIS"
" + A + LIE + THE + TALE + OF + THE + LAST + FIRE + HORSES"
" + LATE + AFTER + THE + FIRST + FATHERS + FORESEE + THE"
" + HORRORS + THE + LAST + FREE + TROLL + TERRIFIES + THE"
" + HORSES + OF + FIRE + THE + TROLL + RESTS + AT + THE +"
" HOLE + OF + LOSSES + IT + IS + THERE + THAT + SHE + STORES"
" + ROLES + OF + LEATHERS + AFTER + SHE + SATISFIES + HER"
" + HATE + OFF + THOSE + FEARS + A + TASTE + RISES + AS +"
" SHE + HEARS + THE + LEAST + FAR + HORSE + THOSE + FAST +"
" HORSES + THAT + FIRST + HEAR + THE + TROLL + FLEE + OFF"
" + TO + THE + FOREST + THE + HORSES + THAT + ALERTS + RAISE"
" + THE + STARES + OF + THE + OTHERS + AS + THE + TROLL +"
" ASSAILS + AT + THE + TOTAL + SHIFT + HER + TEETH + TEAR"
" + HOOF + OFF + TORSO + AS + THE + LAST + HORSE + FORFEITS"
" + ITS + LIFE + THE + FIRST + FATHERS + HEAR + OF + THE +"
" HORRORS + THEIR + FEARS + THAT + THE + FIRES + FOR + THEIR"
" + FEASTS + ARREST + AS + THE + FIRST + FATHERS + RESETTLE +"
" THE + LAST + OF + THE + FIRE + HORSES + THE + LAST + TROLL"
" + HARASSES + THE + FOREST + HEART + FREE + AT + LAST + OF +"
" THE + LAST + TROLL + ALL + OFFER + THEIR + FIRE + HEAT + TO"
" + THE + ASSISTERS + FAR + OFF + THE + TROLL + FASTS + ITS +"
" LIFE + SHORTER + AS + STARS + RISE + THE + HORSES + REST +"
" SAFE + AFTER + ALL + SHARE + HOT + FISH + AS + THEIR +"
" AFFILIATES + TAILOR + A + ROOFS + FOR + THEIR + SAFE =="
" FORTRESSES"
),
{"A": 1,
"E": 0,
"F": 5,
"H": 8,
"I": 7,
"L": 2,
"O": 6,
"R": 3,
"S": 4,
"T": 9})


if __name__ == '__main__':
unittest.main()
16 changes: 1 addition & 15 deletions exercises/anagram/anagram_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,13 @@
from anagram import detect_anagrams


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.1
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.2.0

class AnagramTests(unittest.TestCase):
def test_no_matches(self):
candidates = ["hello", "world", "zombies", "pants"]
self.assertEqual(detect_anagrams("diaper", candidates), [])

def test_detects_simple_anagram(self):
candidates = ["tan", "stand", "at"]
self.assertEqual(detect_anagrams("ant", candidates), ["tan"])

def test_does_not_detect_false_positives(self):
self.assertEqual(detect_anagrams("galea", ["eagle"]), [])

def test_detects_two_anagrams(self):
candidates = ["stream", "pigeon", "maters"]
self.assertEqual(
Expand All @@ -37,10 +30,6 @@ def test_detects_three_anagrams(self):
detect_anagrams("allergy", candidates),
["gallery", "regally", "largely"])

def test_does_not_detect_identical_words(self):
candidates = ["corn", "dark", "Corn", "rank", "CORN", "cron", "park"]
self.assertEqual(detect_anagrams("corn", candidates), ["cron"])

def test_does_not_detect_non_anagrams_with_identical_checksum(self):
self.assertEqual(detect_anagrams("mass", ["last"]), [])

Expand All @@ -59,9 +48,6 @@ def test_detects_anagrams_using_case_insensitive_possible_matches(self):
self.assertEqual(
detect_anagrams("orchestra", candidates), ["Carthorse"])

def test_does_not_detect_a_word_as_its_own_anagram(self):
self.assertEqual(detect_anagrams("banana", ["Banana"]), [])

def test_does_not_detect_a_anagram_if_the_original_word_is_repeated(self):
self.assertEqual(detect_anagrams("go", ["go Go GO"]), [])

Expand Down
2 changes: 1 addition & 1 deletion exercises/atbash-cipher/atbash_cipher_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from atbash_cipher import decode, encode


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.0
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0

class AtbashCipherTest(unittest.TestCase):
def test_encode_no(self):
Expand Down
2 changes: 1 addition & 1 deletion exercises/binary-search/binary_search_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from binary_search import binary_search


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.0
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0

class BinarySearchTests(unittest.TestCase):
def test_finds_value_in_array_with_one_element(self):
Expand Down
57 changes: 18 additions & 39 deletions exercises/book-store/book_store_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,54 @@
from book_store import calculate_total


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.3.0

class BookStoreTests(unittest.TestCase):
def test_only_a_single_book(self):
self.assertAlmostEqual(calculate_total([1]), 8.00,
places=2)
self.assertEqual(calculate_total([1]), 800)

def test_two_of_the_same_book(self):
self.assertAlmostEqual(calculate_total([2, 2]), 16.00,
places=2)
self.assertEqual(calculate_total([2, 2]), 1600)

def test_empty_basket(self):
self.assertAlmostEqual(calculate_total([]), 0.00,
places=2)
self.assertEqual(calculate_total([]), 0)

def test_two_different_books(self):
self.assertAlmostEqual(calculate_total([1, 2]), 15.20,
places=2)
self.assertEqual(calculate_total([1, 2]), 1520)

def test_three_different_books(self):
self.assertAlmostEqual(calculate_total([1, 2, 3]), 21.60,
places=2)
self.assertEqual(calculate_total([1, 2, 3]), 2160)

def test_four_different_books(self):
self.assertAlmostEqual(calculate_total([1, 2, 3, 4]), 25.60,
places=2)
self.assertEqual(calculate_total([1, 2, 3, 4]), 2560)

def test_five_different_books(self):
self.assertAlmostEqual(
calculate_total([1, 2, 3, 4, 5]), 30.00,
places=2)
self.assertEqual(calculate_total([1, 2, 3, 4, 5]), 3000)

def test_two_groups_of_4_is_cheaper_than_group_of_5_plus_group_of_3(self):
self.assertAlmostEqual(
calculate_total([1, 1, 2, 2, 3, 3, 4, 5]), 51.20,
places=2)
self.assertEqual(calculate_total([1, 1, 2, 2, 3, 3, 4, 5]), 5120)

def test_group_of_4_plus_group_of_2_is_cheaper_than_2_groups_of_3(self):
self.assertAlmostEqual(
calculate_total([1, 1, 2, 2, 3, 4]), 40.80,
places=2)
self.assertEqual(calculate_total([1, 1, 2, 2, 3, 4]), 4080)

def test_two_each_of_first_4_books_and_1_copy_each_of_rest(self):
self.assertAlmostEqual(
calculate_total([1, 1, 2, 2, 3, 3, 4, 4, 5]), 55.60,
places=2)
self.assertEqual(calculate_total([1, 1, 2, 2, 3, 3, 4, 4, 5]), 5560)

def test_two_copies_of_each_book(self):
self.assertAlmostEqual(
calculate_total([1, 1, 2, 2, 3, 3, 4, 4, 5, 5]), 60.00,
places=2)
self.assertEqual(calculate_total([1, 1, 2, 2, 3, 3, 4, 4, 5, 5]), 6000)

def test_three_copies_of_first_book_and_2_each_of_remaining(self):
self.assertAlmostEqual(
calculate_total([1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1]),
68.00,
places=2)
self.assertEqual(
calculate_total([1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1]), 6800)

def test_three_each_of_first_2_books_and_2_each_of_remaining_books(self):
self.assertAlmostEqual(
calculate_total([1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2]),
75.20,
places=2)
self.assertEqual(
calculate_total([1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2]), 7520)

def test_four_groups_of_4_are_cheaper_than_2_groups_each_of_5_and_3(self):
self.assertAlmostEqual(
self.assertEqual(
calculate_total([1, 1, 2, 2, 3, 3, 4, 5, 1, 1, 2, 2, 3, 3, 4, 5]),
102.40,
places=2)
10240)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion exercises/book-store/example.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BOOK_PRICE = 8
BOOK_PRICE = 800


def _group_price(size):
Expand Down
2 changes: 1 addition & 1 deletion exercises/bowling/bowling_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from bowling import BowlingGame


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.1
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0

class BowlingTests(unittest.TestCase):
def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion exercises/bracket-push/bracket_push_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from bracket_push import check_brackets


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.2.0

class BracketPushTests(unittest.TestCase):
def test_paired_square_brackets(self):
Expand Down
2 changes: 1 addition & 1 deletion exercises/change/change_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from change import find_minimum_coins

# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0

# Tests adapted from `problem-specifications//canonical-data.json` @ v1.2.0

class ChangeTest(unittest.TestCase):
def test_single_coin_change(self):
Expand Down
2 changes: 1 addition & 1 deletion exercises/circular-buffer/circular_buffer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
)


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.1
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0

class CircularBufferTest(unittest.TestCase):
def test_read_empty_buffer(self):
Expand Down
11 changes: 10 additions & 1 deletion exercises/clock/clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@ class Clock(object):
def __init__(self, hour, minute):
pass

def __add__(self, other):
def __repr__(self):
pass

def __eq__(self, other):
pass

def __add__(self, minutes):
pass

def __sub__(self, minutes):
pass
18 changes: 9 additions & 9 deletions exercises/clock/clock_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from clock import Clock

# Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.1

# Tests adapted from `problem-specifications//canonical-data.json` @ v2.2.1

class ClockTest(unittest.TestCase):
# Test creating a new clock with an initial time.
Expand Down Expand Up @@ -90,28 +90,28 @@ def test_add_more_than_two_days(self):
self.assertEqual(str(Clock(1, 1) + 3500), '11:21')

def test_subtract_minutes(self):
self.assertEqual(str(Clock(10, 3) + -3), '10:00')
self.assertEqual(str(Clock(10, 3) - 3), '10:00')

def test_subtract_to_previous_hour(self):
self.assertEqual(str(Clock(10, 3) + -3), '10:00')
self.assertEqual(str(Clock(10, 3) - 3), '10:00')

def test_subtract_more_than_an_hour(self):
self.assertEqual(str(Clock(10, 3) + -30), '09:33')
self.assertEqual(str(Clock(10, 3) - 30), '09:33')

def test_subtract_across_midnight(self):
self.assertEqual(str(Clock(10, 3) + -70), '08:53')
self.assertEqual(str(Clock(10, 3) - 70), '08:53')

def test_subtract_more_than_two_hours(self):
self.assertEqual(str(Clock(0, 0) + -160), '21:20')
self.assertEqual(str(Clock(0, 0) - 160), '21:20')

def test_subtract_more_than_two_hours_with_borrow(self):
self.assertEqual(str(Clock(6, 15) + -160), '03:35')
self.assertEqual(str(Clock(6, 15) - 160), '03:35')

def test_subtract_more_than_one_day(self):
self.assertEqual(str(Clock(5, 32) + -1500), '04:32')
self.assertEqual(str(Clock(5, 32) - 1500), '04:32')

def test_subtract_more_than_two_days(self):
self.assertEqual(str(Clock(2, 20) + -3000), '00:20')
self.assertEqual(str(Clock(2, 20) - 3000), '00:20')

# Construct two separate clocks, set times, test if they are equal.
def test_clocks_with_same_time(self):
Expand Down
Loading