From 37c0946353ad40fd866114077520babd52756463 Mon Sep 17 00:00:00 2001 From: Dennis Liaw Date: Mon, 21 May 2018 21:43:11 -0400 Subject: [PATCH 01/11] Begins walking the path --- python2/koans/about_asserts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python2/koans/about_asserts.py b/python2/koans/about_asserts.py index 8c80671d7..3789072dc 100644 --- a/python2/koans/about_asserts.py +++ b/python2/koans/about_asserts.py @@ -15,7 +15,7 @@ def test_assert_truth(self): # # http://bit.ly/about_asserts - self.assertTrue(False) # This should be True + self.assertTrue(True) # This should be True def test_assert_with_message(self): """ From 0715f7ad82bc0b8d6357e58416411f923cfdeeeb Mon Sep 17 00:00:00 2001 From: Dennis Liaw Date: Mon, 21 May 2018 21:59:52 -0400 Subject: [PATCH 02/11] continues walking the path --- python2/koans/about_asserts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python2/koans/about_asserts.py b/python2/koans/about_asserts.py index 3789072dc..42df3c05b 100644 --- a/python2/koans/about_asserts.py +++ b/python2/koans/about_asserts.py @@ -21,7 +21,7 @@ def test_assert_with_message(self): """ Enlightenment may be more easily achieved with appropriate messages. """ - self.assertTrue(False, "This should be True -- Please fix this") + self.assertTrue(True, "This should be True -- Please fix this") def test_fill_in_values(self): """ From 8646bb4fd46125a6be61bdd5d3834dc82033b793 Mon Sep 17 00:00:00 2001 From: Dennis Liaw Date: Mon, 21 May 2018 22:01:26 -0400 Subject: [PATCH 03/11] continues the path yet again --- python2/koans/about_asserts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python2/koans/about_asserts.py b/python2/koans/about_asserts.py index 42df3c05b..596eeb51e 100644 --- a/python2/koans/about_asserts.py +++ b/python2/koans/about_asserts.py @@ -27,7 +27,7 @@ def test_fill_in_values(self): """ Sometimes we will ask you to fill in the values """ - self.assertEqual(__, 1 + 1) + self.assertEqual(2, 1 + 1) def test_assert_equality(self): """ From 5ad1ffb4ef283c5ebc00c2b26729eed64ed87e72 Mon Sep 17 00:00:00 2001 From: Dennis Liaw Date: Mon, 21 May 2018 22:27:06 -0400 Subject: [PATCH 04/11] sniffer works! --- python2/koans/about_asserts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python2/koans/about_asserts.py b/python2/koans/about_asserts.py index 596eeb51e..abd164502 100644 --- a/python2/koans/about_asserts.py +++ b/python2/koans/about_asserts.py @@ -34,7 +34,7 @@ def test_assert_equality(self): To understand reality, we must compare our expectations against reality. """ - expected_value = __ + expected_value = 2 actual_value = 1 + 1 self.assertTrue(expected_value == actual_value) From 6e2b3059bfddba4205b61cc2484d82a286a7b84b Mon Sep 17 00:00:00 2001 From: Dennis Liaw Date: Tue, 22 May 2018 10:09:32 -0400 Subject: [PATCH 05/11] ok so the string class is str in python --- python2/koans/about_asserts.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python2/koans/about_asserts.py b/python2/koans/about_asserts.py index abd164502..65cc9e992 100644 --- a/python2/koans/about_asserts.py +++ b/python2/koans/about_asserts.py @@ -42,7 +42,7 @@ def test_a_better_way_of_asserting_equality(self): """ Some ways of asserting equality are better than others. """ - expected_value = __ + expected_value = 2 actual_value = 1 + 1 self.assertEqual(expected_value, actual_value) @@ -53,7 +53,7 @@ def test_that_unittest_asserts_work_the_same_way_as_python_asserts(self): """ # This throws an AssertionError exception - assert False + assert True def test_that_sometimes_we_need_to_know_the_class_type(self): """ @@ -72,7 +72,7 @@ def test_that_sometimes_we_need_to_know_the_class_type(self): # # See for yourself: - self.assertEqual(__, "navel".__class__) # It's str, not + self.assertEqual(str, "navel".__class__) # It's str, not # Need an illustration? More reading can be found here: # From 9d8599d137d209456560bf864dd0daabe9504b39 Mon Sep 17 00:00:00 2001 From: Dennis Liaw Date: Tue, 22 May 2018 10:10:33 -0400 Subject: [PATCH 06/11] TIL basestring is the abstract superclass of str and unicode --- python2/koans/about_strings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python2/koans/about_strings.py b/python2/koans/about_strings.py index abfcf5981..4a6b62a02 100644 --- a/python2/koans/about_strings.py +++ b/python2/koans/about_strings.py @@ -8,11 +8,11 @@ class AboutStrings(Koan): def test_double_quoted_strings_are_strings(self): string = "Hello, world." - self.assertEqual(__, isinstance(string, basestring)) + self.assertEqual(True, isinstance(string, basestring)) def test_single_quoted_strings_are_also_strings(self): string = 'Goodbye, world.' - self.assertEqual(__, isinstance(string, basestring)) + self.assertEqual(True, isinstance(string, basestring)) def test_triple_quote_strings_are_also_strings(self): string = """Howdy, world!""" From b14d4511c5cadcd28099ec857ed6a40fdc866990 Mon Sep 17 00:00:00 2001 From: Dennis Liaw Date: Fri, 1 Jun 2018 13:57:29 -0400 Subject: [PATCH 07/11] Completes about_strings exercises --- python2/koans/about_strings.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python2/koans/about_strings.py b/python2/koans/about_strings.py index 4a6b62a02..c22f33c31 100644 --- a/python2/koans/about_strings.py +++ b/python2/koans/about_strings.py @@ -16,28 +16,28 @@ def test_single_quoted_strings_are_also_strings(self): def test_triple_quote_strings_are_also_strings(self): string = """Howdy, world!""" - self.assertEqual(__, isinstance(string, basestring)) + self.assertEqual(True, isinstance(string, basestring)) def test_triple_single_quotes_work_too(self): string = '''Bonjour tout le monde!''' - self.assertEqual(__, isinstance(string, basestring)) + self.assertEqual(True, isinstance(string, basestring)) def test_raw_strings_are_also_strings(self): string = r"Konnichi wa, world!" - self.assertEqual(__, isinstance(string, basestring)) + self.assertEqual(True, isinstance(string, basestring)) def test_use_single_quotes_to_create_string_with_double_quotes(self): string = 'He said, "Go Away."' - self.assertEqual(__, string) + self.assertEqual('He said, "Go Away."', string) def test_use_double_quotes_to_create_strings_with_single_quotes(self): string = "Don't" - self.assertEqual(__, string) + self.assertEqual("Don't", string) def test_use_backslash_for_escaping_quotes_in_strings(self): a = "He said, \"Don't\"" b = 'He said, "Don\'t"' - self.assertEqual(__, (a == b)) + self.assertEqual(True, (a == b)) def test_use_backslash_at_the_end_of_a_line_to_continue_onto_the_next_line(self): string = "It was the best of times,\n\ From 7fac25ddcfa64599719bcfa6fec068e0feef8686 Mon Sep 17 00:00:00 2001 From: Dennis Liaw Date: Fri, 1 Jun 2018 14:04:07 -0400 Subject: [PATCH 08/11] Triple quotes in Python are aight --- python2/koans/about_strings.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python2/koans/about_strings.py b/python2/koans/about_strings.py index c22f33c31..47f94adfd 100644 --- a/python2/koans/about_strings.py +++ b/python2/koans/about_strings.py @@ -42,19 +42,19 @@ def test_use_backslash_for_escaping_quotes_in_strings(self): def test_use_backslash_at_the_end_of_a_line_to_continue_onto_the_next_line(self): string = "It was the best of times,\n\ It was the worst of times." - self.assertEqual(__, len(string)) + self.assertEqual(52, len(string)) def test_triple_quoted_strings_can_span_lines(self): string = """ Howdy, world! """ - self.assertEqual(__, len(string)) + self.assertEqual(15, len(string)) def test_triple_quoted_strings_need_less_escaping(self): a = "Hello \"world\"." b = """Hello "world".""" - self.assertEqual(__, (a == b)) + self.assertEqual(True, (a == b)) def test_escaping_quotes_at_the_end_of_triple_quoted_string(self): string = """Hello "world\"""" From 0f7dc2a92cc9a34b07f7e1c4cf6dd2781226e485 Mon Sep 17 00:00:00 2001 From: Dennis Liaw Date: Fri, 1 Jun 2018 14:05:22 -0400 Subject: [PATCH 09/11] Remember to escape quotes at the end of a triple quoted string --- python2/koans/about_strings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python2/koans/about_strings.py b/python2/koans/about_strings.py index 47f94adfd..030c6dda9 100644 --- a/python2/koans/about_strings.py +++ b/python2/koans/about_strings.py @@ -58,7 +58,7 @@ def test_triple_quoted_strings_need_less_escaping(self): def test_escaping_quotes_at_the_end_of_triple_quoted_string(self): string = """Hello "world\"""" - self.assertEqual(__, string) + self.assertEqual('Hello "world"', string) def test_plus_concatenates_strings(self): string = "Hello, " + "world" From 7755d0ebc3bde953bc18880ed277fea54ee89e14 Mon Sep 17 00:00:00 2001 From: Dennis Liaw Date: Fri, 1 Jun 2018 14:07:30 -0400 Subject: [PATCH 10/11] Not sure why, but you can concatenate adjacent strings --- python2/koans/about_strings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python2/koans/about_strings.py b/python2/koans/about_strings.py index 030c6dda9..198520cfe 100644 --- a/python2/koans/about_strings.py +++ b/python2/koans/about_strings.py @@ -62,11 +62,11 @@ def test_escaping_quotes_at_the_end_of_triple_quoted_string(self): def test_plus_concatenates_strings(self): string = "Hello, " + "world" - self.assertEqual(__, string) + self.assertEqual('Hello, world', string) def test_adjacent_strings_are_concatenated_automatically(self): string = "Hello" ", " "world" - self.assertEqual(__, string) + self.assertEqual('Hello, world', string) def test_plus_will_not_modify_original_strings(self): hi = "Hello, " From 4ef487efd9e1076e3182651c36b7f3d93338e106 Mon Sep 17 00:00:00 2001 From: Dennis Liaw Date: Fri, 1 Jun 2018 14:29:45 -0400 Subject: [PATCH 11/11] Really completes about_strings koans. Expanded awareness of Python Strings --- python2/koans/about_strings.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/python2/koans/about_strings.py b/python2/koans/about_strings.py index 198520cfe..db23bde2c 100644 --- a/python2/koans/about_strings.py +++ b/python2/koans/about_strings.py @@ -72,24 +72,24 @@ def test_plus_will_not_modify_original_strings(self): hi = "Hello, " there = "world" string = hi + there - self.assertEqual(__, hi) - self.assertEqual(__, there) + self.assertEqual('Hello, ', hi) + self.assertEqual('world', there) def test_plus_equals_will_append_to_end_of_string(self): hi = "Hello, " there = "world" hi += there - self.assertEqual(__, hi) + self.assertEqual('Hello, world', hi) def test_plus_equals_also_leaves_original_string_unmodified(self): original = "Hello, " hi = original there = "world" hi += there - self.assertEqual(__, original) + self.assertEqual('Hello, ', original) def test_most_strings_interpret_escape_characters(self): string = "\n" self.assertEqual('\n', string) self.assertEqual("""\n""", string) - self.assertEqual(__, len(string)) + self.assertEqual(1, len(string))