diff --git a/exercises/bob/bob_test.py b/exercises/bob/bob_test.py index c729da3577..e38c352862 100644 --- a/exercises/bob/bob_test.py +++ b/exercises/bob/bob_test.py @@ -1,123 +1,99 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals import unittest import bob -class BobTests(unittest.TestCase): +# test cases adapted from `x-common//canonical-data.json` @ version: 1.0.0 +class BobTests(unittest.TestCase): def test_stating_something(self): - self.assertEqual( - 'Whatever.', - bob.hey('Tom-ay-to, tom-aaaah-to.') - ) + self.assertEqual(bob.hey("Tom-ay-to, tom-aaaah-to."), "Whatever.") def test_shouting(self): - self.assertEqual( - 'Whoa, chill out!', - bob.hey('WATCH OUT!') - ) + self.assertEqual(bob.hey("WATCH OUT!"), "Whoa, chill out!") + + def test_shouting_gibberish(self): + self.assertEqual(bob.hey("FCECDFCAAB"), "Whoa, chill out!") def test_asking_a_question(self): self.assertEqual( - 'Sure.', - bob.hey('Does this cryogenic chamber make me look fat?') - ) + bob.hey("Does this cryogenic chamber make me look fat?"), "Sure.") def test_asking_a_numeric_question(self): - self.assertEqual( - 'Sure.', - bob.hey('You are, what, like 15?') - ) + self.assertEqual(bob.hey("You are, what, like 15?"), "Sure.") + + def test_asking_gibberish(self): + self.assertEqual(bob.hey("fffbbcbeab?"), "Sure.") def test_talking_forcefully(self): self.assertEqual( - 'Whatever.', - bob.hey("Let's go make out behind the gym!") - ) + bob.hey("Let's go make out behind the gym!"), "Whatever.") def test_using_acronyms_in_regular_speech(self): self.assertEqual( - 'Whatever.', bob.hey("It's OK if you don't want to go to the DMV.") - ) + bob.hey("It's OK if you don't want to go to the DMV."), + "Whatever.") - def test_forceful_questions(self): + def test_forceful_question(self): self.assertEqual( - 'Whoa, chill out!', bob.hey('WHAT THE HELL WERE YOU THINKING?') - ) + bob.hey("WHAT THE HELL WERE YOU THINKING?"), "Whoa, chill out!") def test_shouting_numbers(self): - self.assertEqual( - 'Whoa, chill out!', bob.hey('1, 2, 3 GO!') - ) + self.assertEqual(bob.hey("1, 2, 3 GO!"), "Whoa, chill out!") def test_only_numbers(self): - self.assertEqual( - 'Whatever.', bob.hey('1, 2, 3') - ) + self.assertEqual(bob.hey("1, 2, 3"), "Whatever.") def test_question_with_only_numbers(self): - self.assertEqual( - 'Sure.', bob.hey('4?') - ) + self.assertEqual(bob.hey("4?"), "Sure.") def test_shouting_with_special_characters(self): self.assertEqual( - 'Whoa, chill out!', - bob.hey('ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!') - ) - - def test_shouting_with_umlauts(self): - self.assertEqual( - 'Whoa, chill out!', bob.hey('ÜMLÄÜTS!') - ) - - def test_calmly_speaking_with_umlauts(self): - self.assertEqual( - 'Whatever.', bob.hey('ÜMLäÜTS!') - ) + bob.hey("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"), + "Whoa, chill out!") def test_shouting_with_no_exclamation_mark(self): - self.assertEqual( - 'Whoa, chill out!', bob.hey('I HATE YOU') - ) + self.assertEqual(bob.hey("I HATE YOU"), "Whoa, chill out!") def test_statement_containing_question_mark(self): self.assertEqual( - 'Whatever.', bob.hey('Ending with ? means a question.') - ) + bob.hey("Ending with ? means a question."), "Whatever.") + + def test_non_letters_with_question(self): + self.assertEqual(bob.hey(":) ?"), "Sure.") def test_prattling_on(self): self.assertEqual( - 'Sure.', bob.hey("Wait! Hang on. Are you going to be OK?") - ) + bob.hey("Wait! Hang on. Are you going to be OK?"), "Sure.") def test_silence(self): - self.assertEqual( - 'Fine. Be that way!', bob.hey('') - ) + self.assertEqual(bob.hey(""), "Fine. Be that way!") def test_prolonged_silence(self): - self.assertEqual( - 'Fine. Be that way!', bob.hey(' \t') - ) + self.assertEqual(bob.hey(" "), "Fine. Be that way!") + + def test_alternate_silence(self): + self.assertEqual(bob.hey("\t\t\t\t\t\t\t\t\t\t"), "Fine. Be that way!") - def test_starts_with_whitespace(self): + def test_multiple_line_question(self): self.assertEqual( - 'Whatever.', bob.hey(' hmmmmmmm...') - ) + bob.hey("\nDoes this cryogenic chamber make me look fat?\nno"), + "Whatever.") - def test_ends_with_whitespace(self): + def test_starting_with_whitespace(self): + self.assertEqual(bob.hey(" hmmmmmmm..."), "Whatever.") + + def test_ending_with_whitespace(self): self.assertEqual( - 'Sure.', bob.hey('What if we end with whitespace? ') - ) + bob.hey("Okay if like my spacebar quite a bit? "), "Sure.") + + def test_other_whitespace(self): + self.assertEqual(bob.hey("\n\r \t"), "Fine. Be that way!") - def test_non_question_ends_with_whitespace(self): + def test_non_question_ending_with_whitespace(self): self.assertEqual( - 'Whatever.', bob.hey('This is a statement with trailing whitespace ') - ) + bob.hey("This is a statement ending with whitespace "), + "Whatever.") if __name__ == '__main__':