diff --git a/.travis.yml b/.travis.yml index 3720cb5e1..9054296c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ python: - 2.7 script: - cd python2 - - python contemplate_koans.py about_asserts # add further koans here separated by spaces + - python contemplate_koans.py about_asserts about_none about_lists about_list_assignments about_dictionaries about_strings about_tuples about_methods about_control_statements about_true_and_false about_sets about_generators.py notifications: email: false diff --git a/python2/koans/__init__.pyc b/python2/koans/__init__.pyc new file mode 100644 index 000000000..2f1694674 Binary files /dev/null and b/python2/koans/__init__.pyc differ diff --git a/python2/koans/about_asserts.pyc b/python2/koans/about_asserts.pyc new file mode 100644 index 000000000..e5bd0ad72 Binary files /dev/null and b/python2/koans/about_asserts.pyc differ diff --git a/python2/koans/about_attribute_access.pyc b/python2/koans/about_attribute_access.pyc new file mode 100644 index 000000000..921cc5317 Binary files /dev/null and b/python2/koans/about_attribute_access.pyc differ diff --git a/python2/koans/about_class_attributes.pyc b/python2/koans/about_class_attributes.pyc new file mode 100644 index 000000000..b5a242ed3 Binary files /dev/null and b/python2/koans/about_class_attributes.pyc differ diff --git a/python2/koans/about_classes.pyc b/python2/koans/about_classes.pyc new file mode 100644 index 000000000..76d598bd1 Binary files /dev/null and b/python2/koans/about_classes.pyc differ diff --git a/python2/koans/about_control_statements.py b/python2/koans/about_control_statements.py index 921f0bf7f..3fc23f28f 100644 --- a/python2/koans/about_control_statements.py +++ b/python2/koans/about_control_statements.py @@ -11,13 +11,13 @@ def test_if_then_else_statements(self): result = 'true value' else: result = 'false value' - self.assertEqual(__, result) + self.assertEqual('true value', result) def test_if_then_statements(self): result = 'default value' if True: result = 'true value' - self.assertEqual(__, result) + self.assertEqual('true value', result) def test_while_statement(self): i = 1 @@ -25,7 +25,7 @@ def test_while_statement(self): while i <= 10: result = result * i i += 1 - self.assertEqual(__, result) + self.assertEqual(10*9*8*7*6*5*4*3*2, result) def test_break_statement(self): i = 1 @@ -34,7 +34,7 @@ def test_break_statement(self): if i > 10: break result = result * i i += 1 - self.assertEqual(__, result) + self.assertEqual(10*9*8*7*6*5*4*3*2, result) def test_continue_statement(self): i = 0 @@ -43,14 +43,14 @@ def test_continue_statement(self): i += 1 if (i % 2) == 0: continue result.append(i) - self.assertEqual(__, result) + self.assertEqual([1,3,5,7,9], result) def test_for_statement(self): phrase = ["fish", "and", "chips"] result = [] for item in phrase: result.append(item.upper()) - self.assertEqual([__, __, __], result) + self.assertEqual(["FISH","AND","CHIPS"], result) def test_for_statement_with_tuples(self): round_table = [ @@ -64,7 +64,7 @@ def test_for_statement_with_tuples(self): result.append("Contestant: '" + knight + \ "' Answer: '" + answer + "'") - text = __ + text = "Contestant: 'Robin' Answer: 'Blue! I mean Green!'" self.assertMatch(text, result[2]) diff --git a/python2/koans/about_control_statements.pyc b/python2/koans/about_control_statements.pyc new file mode 100644 index 000000000..89d4d6dee Binary files /dev/null and b/python2/koans/about_control_statements.pyc differ diff --git a/python2/koans/about_decorating_with_classes.pyc b/python2/koans/about_decorating_with_classes.pyc new file mode 100644 index 000000000..08445dd3b Binary files /dev/null and b/python2/koans/about_decorating_with_classes.pyc differ diff --git a/python2/koans/about_decorating_with_functions.pyc b/python2/koans/about_decorating_with_functions.pyc new file mode 100644 index 000000000..1793e7784 Binary files /dev/null and b/python2/koans/about_decorating_with_functions.pyc differ diff --git a/python2/koans/about_deleting_objects.pyc b/python2/koans/about_deleting_objects.pyc new file mode 100644 index 000000000..2f7169bed Binary files /dev/null and b/python2/koans/about_deleting_objects.pyc differ diff --git a/python2/koans/about_dice_project.pyc b/python2/koans/about_dice_project.pyc new file mode 100644 index 000000000..86edec05e Binary files /dev/null and b/python2/koans/about_dice_project.pyc differ diff --git a/python2/koans/about_dictionaries.py b/python2/koans/about_dictionaries.py index 518ea54bf..f65fd43a1 100644 --- a/python2/koans/about_dictionaries.py +++ b/python2/koans/about_dictionaries.py @@ -13,40 +13,40 @@ def test_creating_dictionaries(self): empty_dict = dict() self.assertEqual(dict, type(empty_dict)) self.assertEqual(dict(), empty_dict) - self.assertEqual(__, len(empty_dict)) + self.assertEqual(0, len(empty_dict)) def test_dictionary_literals(self): empty_dict = {} self.assertEqual(dict, type(empty_dict)) babel_fish = {'one': 'uno', 'two': 'dos'} - self.assertEqual(__, len(babel_fish)) + self.assertEqual(2, len(babel_fish)) def test_accessing_dictionaries(self): babel_fish = {'one': 'uno', 'two': 'dos'} - self.assertEqual(__, babel_fish['one']) - self.assertEqual(__, babel_fish['two']) + self.assertEqual('uno', babel_fish['one']) + self.assertEqual('dos', babel_fish['two']) def test_changing_dictionaries(self): babel_fish = {'one': 'uno', 'two': 'dos'} babel_fish['one'] = 'eins' - expected = {'two': 'dos', 'one': __} + expected = {'two': 'dos', 'one': 'eins'} self.assertEqual(expected, babel_fish) def test_dictionary_is_unordered(self): dict1 = {'one': 'uno', 'two': 'dos'} dict2 = {'two': 'dos', 'one': 'uno'} - self.assertEqual(____, dict1 == dict2) + self.assertEqual(True, dict1 == dict2) def test_dictionary_keys_and_values(self): babel_fish = {'one': 'uno', 'two': 'dos'} - self.assertEqual(__, len(babel_fish.keys())) - self.assertEqual(__, len(babel_fish.values())) - self.assertEqual(__, 'one' in babel_fish.keys()) - self.assertEqual(__, 'two' in babel_fish.values()) - self.assertEqual(__, 'uno' in babel_fish.keys()) - self.assertEqual(__, 'dos' in babel_fish.values()) + self.assertEqual(2, len(babel_fish.keys())) + self.assertEqual(2, len(babel_fish.values())) + self.assertEqual(True, 'one' in babel_fish.keys()) + self.assertEqual(False, 'two' in babel_fish.values()) + self.assertEqual(False, 'uno' in babel_fish.keys()) + self.assertEqual(True, 'dos' in babel_fish.values()) def test_making_a_dictionary_from_a_sequence_of_keys(self): cards = {}.fromkeys( @@ -54,6 +54,6 @@ def test_making_a_dictionary_from_a_sequence_of_keys(self): 'confused looking zebra'), 42) - self.assertEqual(__, len(cards)) - self.assertEqual(__, cards['green elf']) - self.assertEqual(__, cards['yellow dwarf']) + self.assertEqual(5, len(cards)) + self.assertEqual(42, cards['green elf']) + self.assertEqual(42, cards['yellow dwarf']) diff --git a/python2/koans/about_dictionaries.pyc b/python2/koans/about_dictionaries.pyc new file mode 100644 index 000000000..fe2da31c1 Binary files /dev/null and b/python2/koans/about_dictionaries.pyc differ diff --git a/python2/koans/about_exceptions.pyc b/python2/koans/about_exceptions.pyc new file mode 100644 index 000000000..9e132dd8d Binary files /dev/null and b/python2/koans/about_exceptions.pyc differ diff --git a/python2/koans/about_extra_credit.pyc b/python2/koans/about_extra_credit.pyc new file mode 100644 index 000000000..45712ba67 Binary files /dev/null and b/python2/koans/about_extra_credit.pyc differ diff --git a/python2/koans/about_generators.py b/python2/koans/about_generators.py index dd31b91f9..2b13a3368 100644 --- a/python2/koans/about_generators.py +++ b/python2/koans/about_generators.py @@ -19,7 +19,7 @@ def test_generating_values_on_the_fly(self): n in ['crunchy', 'veggie', 'danish']) for bacon in bacon_generator: result.append(bacon) - self.assertEqual(__, result) + self.assertEqual(['crunchy bacon', 'veggie bacon', 'danish bacon'], result) def test_generators_are_different_to_list_comprehensions(self): num_list = [x * 2 for x in range(1, 3)] @@ -28,7 +28,7 @@ def test_generators_are_different_to_list_comprehensions(self): self.assertEqual(2, num_list[0]) # A generator has to be iterated through. - self.assertEqual(__, list(num_generator)[0]) + self.assertEqual(2, list(num_generator)[0]) # Both list comprehensions and generators can be iterated # though. However, a generator function is only called on the @@ -43,8 +43,8 @@ def test_generator_expressions_are_a_one_shot_deal(self): attempt1 = list(dynamite) attempt2 = list(dynamite) - self.assertEqual(__, list(attempt1)) - self.assertEqual(__, list(attempt2)) + self.assertEqual(['Boom!', 'Boom!', 'Boom!'], list(attempt1)) + self.assertEqual([], list(attempt2)) # ------------------------------------------------------------------ @@ -58,12 +58,12 @@ def test_generator_method_will_yield_values_during_iteration(self): result = list() for item in self.simple_generator_method(): result.append(item) - self.assertEqual(__, result) + self.assertEqual(['peanut', 'butter', 'and', 'jelly'], result) def test_coroutines_can_take_arguments(self): result = self.simple_generator_method() - self.assertEqual(__, next(result)) - self.assertEqual(__, next(result)) + self.assertEqual('peanut', next(result)) + self.assertEqual('butter', next(result)) result.close() # ------------------------------------------------------------------ @@ -74,7 +74,7 @@ def square_me(self, seq): def test_generator_method_with_parameter(self): result = self.square_me(range(2, 5)) - self.assertEqual(__, list(result)) + self.assertEqual([4,9,16], list(result)) # ------------------------------------------------------------------ @@ -87,7 +87,7 @@ def sum_it(self, seq): def test_generator_keeps_track_of_local_variables(self): result = self.sum_it(range(2, 5)) - self.assertEqual(__, list(result)) + self.assertEqual([2, 5, 9], list(result)) # ------------------------------------------------------------------ @@ -105,7 +105,7 @@ def test_generators_can_take_coroutines(self): # section of http://www.python.org/dev/peps/pep-0342/ next(generator) - self.assertEqual(__, generator.send(1 + 2)) + self.assertEqual(3, generator.send(1 + 2)) def test_before_sending_a_value_to_a_generator_next_must_be_called(self): generator = self.generator_with_coroutine() @@ -113,7 +113,7 @@ def test_before_sending_a_value_to_a_generator_next_must_be_called(self): try: generator.send(1 + 2) except TypeError as ex: - self.assertMatch(__, ex[0]) + self.assertMatch("can't send non-None value to a just-started generator", ex[0]) # ------------------------------------------------------------------ @@ -131,11 +131,11 @@ def test_generators_can_see_if_they_have_been_called_with_a_value(self): generator2 = self.yield_tester() next(generator2) - self.assertEqual(__, next(generator2)) + self.assertEqual('no value', next(generator2)) def test_send_none_is_equivalent_to_next(self): generator = self.yield_tester() next(generator) # 'next(generator)' is exactly equivalent to 'generator.send(None)' - self.assertEqual(__, generator.send(None)) + self.assertEqual('no value', generator.send(None)) diff --git a/python2/koans/about_generators.pyc b/python2/koans/about_generators.pyc new file mode 100644 index 000000000..96f2fd846 Binary files /dev/null and b/python2/koans/about_generators.pyc differ diff --git a/python2/koans/about_inheritance.pyc b/python2/koans/about_inheritance.pyc new file mode 100644 index 000000000..0881bc5ff Binary files /dev/null and b/python2/koans/about_inheritance.pyc differ diff --git a/python2/koans/about_iteration.pyc b/python2/koans/about_iteration.pyc new file mode 100644 index 000000000..b72377c24 Binary files /dev/null and b/python2/koans/about_iteration.pyc differ diff --git a/python2/koans/about_lambdas.pyc b/python2/koans/about_lambdas.pyc new file mode 100644 index 000000000..4b08178ca Binary files /dev/null and b/python2/koans/about_lambdas.pyc differ diff --git a/python2/koans/about_list_assignments.py b/python2/koans/about_list_assignments.py index 812a862ec..369781145 100644 --- a/python2/koans/about_list_assignments.py +++ b/python2/koans/about_list_assignments.py @@ -11,21 +11,21 @@ class AboutListAssignments(Koan): def test_non_parallel_assignment(self): names = ["John", "Smith"] - self.assertEqual(__, names) + self.assertEqual(['John', 'Smith'], names) def test_parallel_assignments(self): first_name, last_name = ["John", "Smith"] - self.assertEqual(__, first_name) - self.assertEqual(__, last_name) + self.assertEqual("John", first_name) + self.assertEqual("Smith", last_name) def test_parallel_assignments_with_sublists(self): first_name, last_name = [["Willie", "Rae"], "Johnson"] - self.assertEqual(__, first_name) - self.assertEqual(__, last_name) + self.assertEqual(["Willie", "Rae"], first_name) + self.assertEqual("Johnson", last_name) def test_swapping_with_parallel_assignment(self): first_name = "Roy" last_name = "Rob" first_name, last_name = last_name, first_name - self.assertEqual(__, first_name) - self.assertEqual(__, last_name) + self.assertEqual("Rob", first_name) + self.assertEqual("Roy", last_name) diff --git a/python2/koans/about_list_assignments.pyc b/python2/koans/about_list_assignments.pyc new file mode 100644 index 000000000..0256e74c4 Binary files /dev/null and b/python2/koans/about_list_assignments.pyc differ diff --git a/python2/koans/about_lists.py b/python2/koans/about_lists.py index 6a0a7847e..285125e0e 100644 --- a/python2/koans/about_lists.py +++ b/python2/koans/about_lists.py @@ -12,7 +12,7 @@ class AboutLists(Koan): def test_creating_lists(self): empty_list = list() self.assertEqual(list, type(empty_list)) - self.assertEqual(__, len(empty_list)) + self.assertEqual(0, len(empty_list)) def test_list_literals(self): nums = list() @@ -22,68 +22,68 @@ def test_list_literals(self): self.assertEqual([1], nums) nums[1:] = [2] - self.assertEqual([1, __], nums) + self.assertEqual([1, 2], nums) nums.append(333) - self.assertEqual([1, 2, __], nums) + self.assertEqual([1, 2, 333], nums) def test_accessing_list_elements(self): noms = ['peanut', 'butter', 'and', 'jelly'] - self.assertEqual(__, noms[0]) - self.assertEqual(__, noms[3]) - self.assertEqual(__, noms[-1]) - self.assertEqual(__, noms[-3]) + self.assertEqual('peanut', noms[0]) + self.assertEqual('jelly', noms[3]) + self.assertEqual('jelly', noms[-1]) + self.assertEqual('butter', noms[-3]) def test_slicing_lists(self): noms = ['peanut', 'butter', 'and', 'jelly'] - self.assertEqual(__, noms[0:1]) - self.assertEqual(__, noms[0:2]) - self.assertEqual(__, noms[2:2]) - self.assertEqual(__, noms[2:20]) - self.assertEqual(__, noms[4:0]) - self.assertEqual(__, noms[4:100]) - self.assertEqual(__, noms[5:0]) + self.assertEqual(['peanut'], noms[0:1]) + self.assertEqual(['peanut', 'butter'], noms[0:2]) + self.assertEqual([], noms[2:2]) + self.assertEqual(['and','jelly'], noms[2:20]) + self.assertEqual([], noms[4:0]) + self.assertEqual([], noms[4:100]) + self.assertEqual([], noms[5:0]) def test_slicing_to_the_edge(self): noms = ['peanut', 'butter', 'and', 'jelly'] - self.assertEqual(__, noms[2:]) - self.assertEqual(__, noms[:2]) + self.assertEqual(['and', 'jelly'], noms[2:]) + self.assertEqual(['peanut', 'butter'], noms[:2]) def test_lists_and_ranges(self): self.assertEqual(list, type(range(5))) - self.assertEqual(__, range(5)) - self.assertEqual(__, range(5, 9)) + self.assertEqual([0,1,2,3,4], range(5)) + self.assertEqual([5,6,7,8], range(5, 9)) def test_ranges_with_steps(self): - self.assertEqual(__, range(0, 8, 2)) - self.assertEqual(__, range(1, 8, 3)) - self.assertEqual(__, range(5, -7, -4)) - self.assertEqual(__, range(5, -8, -4)) + self.assertEqual([0,2,4,6], range(0, 8, 2)) + self.assertEqual([1,4,7], range(1, 8, 3)) + self.assertEqual([5,1,-3], range(5, -7, -4)) + self.assertEqual([5,1,-3,-7], range(5, -8, -4)) def test_insertions(self): knight = ['you', 'shall', 'pass'] knight.insert(2, 'not') - self.assertEqual(__, knight) + self.assertEqual(['you', 'shall', 'not', 'pass'], knight) knight.insert(0, 'Arthur') - self.assertEqual(__, knight) + self.assertEqual(['Arthur','you', 'shall', 'not', 'pass'], knight) def test_popping_lists(self): stack = [10, 20, 30, 40] stack.append('last') - self.assertEqual(__, stack) + self.assertEqual([10, 20, 30, 40, 'last'], stack) popped_value = stack.pop() - self.assertEqual(__, popped_value) - self.assertEqual(__, stack) + self.assertEqual('last', popped_value) + self.assertEqual([10, 20, 30, 40], stack) popped_value = stack.pop(1) - self.assertEqual(__, popped_value) - self.assertEqual(__, stack) + self.assertEqual(20, popped_value) + self.assertEqual([10, 30, 40], stack) # Notice that there is a "pop" but no "push" in python? @@ -99,8 +99,8 @@ def test_use_deques_for_making_queues(self): queue = deque([1, 2]) queue.append('last') - self.assertEqual(__, list(queue)) + self.assertEqual([1, 2, 'last'], list(queue)) popped_value = queue.popleft() - self.assertEqual(__, popped_value) - self.assertEqual(__, list(queue)) + self.assertEqual(1, popped_value) + self.assertEqual([2, 'last'], list(queue)) diff --git a/python2/koans/about_lists.pyc b/python2/koans/about_lists.pyc new file mode 100644 index 000000000..bab94cddc Binary files /dev/null and b/python2/koans/about_lists.pyc differ diff --git a/python2/koans/about_method_bindings.pyc b/python2/koans/about_method_bindings.pyc new file mode 100644 index 000000000..35030018b Binary files /dev/null and b/python2/koans/about_method_bindings.pyc differ diff --git a/python2/koans/about_methods.py b/python2/koans/about_methods.py index 173cd0ce3..43b1112ac 100644 --- a/python2/koans/about_methods.py +++ b/python2/koans/about_methods.py @@ -14,7 +14,7 @@ def my_global_function(a, b): class AboutMethods(Koan): def test_calling_a_global_function(self): - self.assertEqual(__, my_global_function(2, 3)) + self.assertEqual(5, my_global_function(2, 3)) # NOTE: Wrong number of arguments is not a SYNTAX error, but a # runtime error. @@ -22,7 +22,7 @@ def test_calling_functions_with_wrong_number_of_arguments(self): try: my_global_function() except Exception as exception: - self.assertEqual(__, type(exception).__name__) + self.assertEqual('TypeError', type(exception).__name__) self.assertMatch( r'my_global_function\(\) takes exactly 2 arguments \(0 given\)', exception[0]) @@ -32,7 +32,7 @@ def test_calling_functions_with_wrong_number_of_arguments(self): except Exception as e: # Note, watch out for parenthesis. They need slashes in front! - self.assertMatch(__, e[0]) + self.assertMatch('my_global_function()', e[0]) # ------------------------------------------------------------------ @@ -40,7 +40,7 @@ def pointless_method(self, a, b): sum = a + b def test_which_does_not_return_anything(self): - self.assertEqual(__, self.pointless_method(1, 2)) + self.assertEqual(None, self.pointless_method(1, 2)) # Notice that methods accessed from class scope do not require # you to pass the first "self" argument? @@ -50,8 +50,8 @@ def method_with_defaults(self, a, b='default_value'): return [a, b] def test_calling_with_default_values(self): - self.assertEqual(__, self.method_with_defaults(1)) - self.assertEqual(__, self.method_with_defaults(1, 2)) + self.assertEqual([1, 'default_value'], self.method_with_defaults(1)) + self.assertEqual([1,2], self.method_with_defaults(1, 2)) # ------------------------------------------------------------------ @@ -59,9 +59,9 @@ def method_with_var_args(self, *args): return args def test_calling_with_variable_arguments(self): - self.assertEqual(__, self.method_with_var_args()) + self.assertEqual((), self.method_with_var_args()) self.assertEqual(('one', ), self.method_with_var_args('one')) - self.assertEqual(__, self.method_with_var_args('one', 'two')) + self.assertEqual(('one','two'), self.method_with_var_args('one', 'two')) # ------------------------------------------------------------------ @@ -72,13 +72,13 @@ def test_functions_without_self_arg_are_global_functions(self): def function_with_the_same_name(a, b): return a * b - self.assertEqual(__, function_with_the_same_name(3, 4)) + self.assertEqual(12, function_with_the_same_name(3, 4)) def test_calling_methods_in_same_class_with_explicit_receiver(self): def function_with_the_same_name(a, b): return a * b - self.assertEqual(__, self.function_with_the_same_name(3, 4)) + self.assertEqual(7, self.function_with_the_same_name(3, 4)) # ------------------------------------------------------------------ @@ -91,10 +91,10 @@ def another_method_with_the_same_name(self): return 42 def test_that_old_methods_are_hidden_by_redefinitions(self): - self.assertEqual(__, self.another_method_with_the_same_name()) + self.assertEqual(42, self.another_method_with_the_same_name()) def test_that_overlapped_method_is_still_there(self): - self.assertEqual(__, self.link_to_overlapped_method()) + self.assertEqual(10, self.link_to_overlapped_method()) # ------------------------------------------------------------------ @@ -102,21 +102,21 @@ def empty_method(self): pass def test_methods_that_do_nothing_need_to_use_pass_as_a_filler(self): - self.assertEqual(__, self.empty_method()) + self.assertEqual(None, self.empty_method()) def test_pass_does_nothing_at_all(self): "You" "shall" "not" pass - self.assertEqual(____, "Still got to this line" != None) + self.assertEqual(True, "Still got to this line" != None) # ------------------------------------------------------------------ def one_line_method(self): return 'Madagascar' def test_no_indentation_required_for_one_line_statement_bodies(self): - self.assertEqual(__, self.one_line_method()) + self.assertEqual('Madagascar', self.one_line_method()) # ------------------------------------------------------------------ @@ -125,7 +125,7 @@ def method_with_documentation(self): return "ok" def test_the_documentation_can_be_viewed_with_the_doc_method(self): - self.assertMatch(__, self.method_with_documentation.__doc__) + self.assertMatch("A string placed at the beginning of a function is used for documentation", self.method_with_documentation.__doc__) # ------------------------------------------------------------------ @@ -142,13 +142,13 @@ def __password(self): def test_calling_methods_in_other_objects(self): rover = self.Dog() - self.assertEqual(__, rover.name()) + self.assertEqual('Fido', rover.name()) def test_private_access_is_implied_but_not_enforced(self): rover = self.Dog() # This is a little rude, but legal - self.assertEqual(__, rover._tail()) + self.assertEqual('wagging', rover._tail()) def test_double_underscore_attribute_prefixes_cause_name_mangling(self): """Attributes names that start with a double underscore get @@ -158,10 +158,10 @@ def test_double_underscore_attribute_prefixes_cause_name_mangling(self): #This may not be possible... password = rover.__password() except Exception as ex: - self.assertEqual(__, type(ex).__name__) + self.assertEqual('AttributeError', type(ex).__name__) # But this still is! - self.assertEqual(__, rover._Dog__password()) + self.assertEqual('password', rover._Dog__password()) # Name mangling exists to avoid name clash issues when subclassing. # It is not for providing effective access protection diff --git a/python2/koans/about_methods.pyc b/python2/koans/about_methods.pyc new file mode 100644 index 000000000..4599be84a Binary files /dev/null and b/python2/koans/about_methods.pyc differ diff --git a/python2/koans/about_modules.pyc b/python2/koans/about_modules.pyc new file mode 100644 index 000000000..2aa4f31d3 Binary files /dev/null and b/python2/koans/about_modules.pyc differ diff --git a/python2/koans/about_monkey_patching.pyc b/python2/koans/about_monkey_patching.pyc new file mode 100644 index 000000000..0599b9ed1 Binary files /dev/null and b/python2/koans/about_monkey_patching.pyc differ diff --git a/python2/koans/about_multiple_inheritance.pyc b/python2/koans/about_multiple_inheritance.pyc new file mode 100644 index 000000000..09c951e99 Binary files /dev/null and b/python2/koans/about_multiple_inheritance.pyc differ diff --git a/python2/koans/about_new_style_classes.pyc b/python2/koans/about_new_style_classes.pyc new file mode 100644 index 000000000..c0bef817e Binary files /dev/null and b/python2/koans/about_new_style_classes.pyc differ diff --git a/python2/koans/about_none.py b/python2/koans/about_none.py index beeab8274..2fe9ddbaf 100644 --- a/python2/koans/about_none.py +++ b/python2/koans/about_none.py @@ -12,11 +12,11 @@ class AboutNone(Koan): def test_none_is_an_object(self): "Unlike NULL in a lot of languages" - self.assertEqual(__, isinstance(None, object)) + self.assertEqual(True, isinstance(None, object)) def test_none_is_universal(self): "There is only one None" - self.assertEqual(__, None is None) + self.assertEqual(True, None is None) def test_what_exception_do_you_get_when_calling_nonexistent_methods(self): """ @@ -33,15 +33,14 @@ def test_what_exception_do_you_get_when_calling_nonexistent_methods(self): None.some_method_none_does_not_know_about() except Exception as ex: # What exception has been caught? - self.assertEqual(__, ex.__class__.__name__) - + self.assertEqual('AttributeError', ex.__class__.__name__) # What message was attached to the exception? # (HINT: replace __ with part of the error message.) - self.assertMatch(__, ex.args[0]) + self.assertMatch('NoneType', ex.args[0]) def test_none_is_distinct(self): """ None is distinct from other things which are False. """ - self.assertEqual(____, None is not 0) - self.assertEqual(____, None is not False) + self.assertEqual(True, None is not 0) + self.assertEqual(True, None is not False) diff --git a/python2/koans/about_none.pyc b/python2/koans/about_none.pyc new file mode 100644 index 000000000..b5d5ae4b8 Binary files /dev/null and b/python2/koans/about_none.pyc differ diff --git a/python2/koans/about_packages.pyc b/python2/koans/about_packages.pyc new file mode 100644 index 000000000..c040c4da2 Binary files /dev/null and b/python2/koans/about_packages.pyc differ diff --git a/python2/koans/about_proxy_object_project.pyc b/python2/koans/about_proxy_object_project.pyc new file mode 100644 index 000000000..946cfa1de Binary files /dev/null and b/python2/koans/about_proxy_object_project.pyc differ diff --git a/python2/koans/about_regex.pyc b/python2/koans/about_regex.pyc new file mode 100644 index 000000000..f1941fa99 Binary files /dev/null and b/python2/koans/about_regex.pyc differ diff --git a/python2/koans/about_scope.pyc b/python2/koans/about_scope.pyc new file mode 100644 index 000000000..314eb3845 Binary files /dev/null and b/python2/koans/about_scope.pyc differ diff --git a/python2/koans/about_scoring_project.pyc b/python2/koans/about_scoring_project.pyc new file mode 100644 index 000000000..2a2a9d07a Binary files /dev/null and b/python2/koans/about_scoring_project.pyc differ diff --git a/python2/koans/about_sets.py b/python2/koans/about_sets.py index 86403d5d5..119b939c7 100644 --- a/python2/koans/about_sets.py +++ b/python2/koans/about_sets.py @@ -11,13 +11,13 @@ def test_sets_make_keep_lists_unique(self): there_can_only_be_only_one = set(highlanders) - self.assertEqual(__, there_can_only_be_only_one) + self.assertEqual(set(['Malcolm', 'MacLeod', 'Ramirez', 'Matunas']), there_can_only_be_only_one) def test_sets_are_unordered(self): - self.assertEqual(set([__, __, __, __, __]), set('12345')) + self.assertEqual(set(['4', '3', '1', '2', '5']), set('12345')) def test_convert_the_set_into_a_list_to_sort_it(self): - self.assertEqual(__, sorted(set('13245'))) + self.assertEqual(['1','2','3','4','5'], sorted(set('13245'))) # ------------------------------------------------------------------ @@ -25,19 +25,19 @@ def test_set_have_arithmetic_operators(self): scotsmen = set(['MacLeod', 'Wallace', 'Willie']) warriors = set(['MacLeod', 'Wallace', 'Leonidas']) - self.assertEqual(__, scotsmen - warriors) - self.assertEqual(__, scotsmen | warriors) - self.assertEqual(__, scotsmen & warriors) - self.assertEqual(__, scotsmen ^ warriors) + self.assertEqual(set(['Willie']), scotsmen - warriors) + self.assertEqual(set(['Wallace', 'MacLeod', 'Willie', 'Leonidas']), scotsmen | warriors) + self.assertEqual(set(['MacLeod', 'Wallace']), scotsmen & warriors) + self.assertEqual(set(['Willie', 'Leonidas']), scotsmen ^ warriors) # ------------------------------------------------------------------ def test_we_can_query_set_membership(self): - self.assertEqual(__, 127 in set([127, 0, 0, 1])) - self.assertEqual(__, 'cow' not in set('apocalypse now')) + self.assertEqual(True, 127 in set([127, 0, 0, 1])) + self.assertEqual(True, 'cow' not in set('apocalypse now')) def test_we_can_compare_subsets(self): - self.assertEqual(__, set('cake') <= set('cherry cake')) - self.assertEqual(__, set('cake').issubset(set('cherry cake'))) + self.assertEqual(True, set('cake') <= set('cherry cake')) + self.assertEqual(True, set('cake').issubset(set('cherry cake'))) - self.assertEqual(__, set('cake') > set('pie')) + self.assertEqual(False, set('cake') > set('pie')) diff --git a/python2/koans/about_sets.pyc b/python2/koans/about_sets.pyc new file mode 100644 index 000000000..036e749d4 Binary files /dev/null and b/python2/koans/about_sets.pyc differ diff --git a/python2/koans/about_strings.py b/python2/koans/about_strings.py index af8671b44..7f09c94f5 100644 --- a/python2/koans/about_strings.py +++ b/python2/koans/about_strings.py @@ -8,102 +8,102 @@ 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!""" - 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\ 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 but_quotes_at_the_end_of_a_triple_quoted_string_are_still_tricky(self): string = """Hello "world\"""" 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, " 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)) def test_use_format_to_interpolate_variables(self): value1 = 'one' value2 = 2 string = "The values are {0} and {1}".format(value1, value2) - self.assertEqual(__, string) + self.assertEqual("The values are one and 2", string) def test_formatted_values_con_be_shown_in_any_order_or_be_repeated(self): value1 = 'doh' value2 = 'DOH' string = "The values are {1}, {0}, {0} and {1}!".format(value1, value2) - self.assertEqual(__, string) + self.assertEqual("The values are DOH, doh, doh and DOH!", string) def test_any_python_expression_may_be_interpolated(self): import math # import a standard python module with math functions @@ -111,24 +111,24 @@ def test_any_python_expression_may_be_interpolated(self): decimal_places = 4 string = "The square root of 5 is {0:.{1}f}".format(math.sqrt(5), \ decimal_places) - self.assertEqual(__, string) + self.assertEqual("The square root of 5 is 2.2361", string) def test_you_can_get_a_substring_from_a_string(self): string = "Bacon, lettuce and tomato" - self.assertEqual(__, string[7:10]) + self.assertEqual("let", string[7:10]) def test_you_can_get_a_single_character_from_a_string(self): string = "Bacon, lettuce and tomato" - self.assertEqual(__, string[1]) + self.assertEqual('a', string[1]) def test_single_characters_can_be_represented_by_integers(self): - self.assertEqual(__, ord('a')) - self.assertEqual(__, ord('b') == (ord('a') + 1)) + self.assertEqual(97, ord('a')) + self.assertEqual(True, ord('b') == (ord('a') + 1)) def test_strings_can_be_split(self): string = "Sausage Egg Cheese" words = string.split() - self.assertEqual([__, __, __], words) + self.assertEqual(["Sausage", "Egg", "Cheese"], words) def test_strings_can_be_split_with_different_patterns(self): import re # import python regular expression library @@ -138,7 +138,7 @@ def test_strings_can_be_split_with_different_patterns(self): words = pattern.split(string) - self.assertEqual([__, __, __, __], words) + self.assertEqual(["the", "rain", "in", "spain"], words) # `pattern` is a Python regular expression pattern which matches # ',' or ';' @@ -146,18 +146,18 @@ def test_strings_can_be_split_with_different_patterns(self): def test_raw_strings_do_not_interpret_escape_characters(self): string = r'\n' self.assertNotEqual('\n', string) - self.assertEqual(__, string) - self.assertEqual(__, len(string)) + self.assertEqual('\\n', string) + self.assertEqual(2, len(string)) # Useful in regular expressions, file paths, URLs, etc. def test_strings_can_be_joined(self): words = ["Now", "is", "the", "time"] - self.assertEqual(__, ' '.join(words)) + self.assertEqual("Now is the time", ' '.join(words)) def test_strings_can_change_case(self): - self.assertEqual(__, 'guido'.capitalize()) - self.assertEqual(__, 'guido'.upper()) - self.assertEqual(__, 'TimBot'.lower()) - self.assertEqual(__, 'guido van rossum'.title()) - self.assertEqual(__, 'ToTaLlY aWeSoMe'.swapcase()) + self.assertEqual('Guido', 'guido'.capitalize()) + self.assertEqual('GUIDO', 'guido'.upper()) + self.assertEqual('timbot', 'TimBot'.lower()) + self.assertEqual('Guido Van Rossum', 'guido van rossum'.title()) + self.assertEqual('tOtAlLy AwEsOmE', 'ToTaLlY aWeSoMe'.swapcase()) diff --git a/python2/koans/about_strings.pyc b/python2/koans/about_strings.pyc new file mode 100644 index 000000000..220bdf132 Binary files /dev/null and b/python2/koans/about_strings.pyc differ diff --git a/python2/koans/about_triangle_project.pyc b/python2/koans/about_triangle_project.pyc new file mode 100644 index 000000000..77382d9d8 Binary files /dev/null and b/python2/koans/about_triangle_project.pyc differ diff --git a/python2/koans/about_triangle_project2.pyc b/python2/koans/about_triangle_project2.pyc new file mode 100644 index 000000000..891fe1984 Binary files /dev/null and b/python2/koans/about_triangle_project2.pyc differ diff --git a/python2/koans/about_true_and_false.py b/python2/koans/about_true_and_false.py index e29823cb6..bbdd8e844 100644 --- a/python2/koans/about_true_and_false.py +++ b/python2/koans/about_true_and_false.py @@ -12,30 +12,30 @@ def truth_value(self, condition): return 'false stuff' def test_true_is_treated_as_true(self): - self.assertEqual(__, self.truth_value(True)) + self.assertEqual('true stuff', self.truth_value(True)) def test_false_is_treated_as_false(self): - self.assertEqual(__, self.truth_value(False)) + self.assertEqual('false stuff', self.truth_value(False)) def test_none_is_treated_as_false(self): - self.assertEqual(__, self.truth_value(None)) + self.assertEqual('false stuff', self.truth_value(None)) def test_zero_is_treated_as_false(self): - self.assertEqual(__, self.truth_value(0)) + self.assertEqual('false stuff', self.truth_value(0)) def test_empty_collections_are_treated_as_false(self): - self.assertEqual(__, self.truth_value([])) - self.assertEqual(__, self.truth_value(())) - self.assertEqual(__, self.truth_value({})) - self.assertEqual(__, self.truth_value(set())) + self.assertEqual('false stuff', self.truth_value([])) + self.assertEqual('false stuff', self.truth_value(())) + self.assertEqual('false stuff', self.truth_value({})) + self.assertEqual('false stuff', self.truth_value(set())) def test_blank_strings_are_treated_as_false(self): - self.assertEqual(__, self.truth_value("")) + self.assertEqual('false stuff', self.truth_value("")) def test_everything_else_is_treated_as_true(self): - self.assertEqual(__, self.truth_value(1)) - self.assertEqual(__, self.truth_value(1,)) + self.assertEqual('true stuff', self.truth_value(1)) + self.assertEqual('true stuff', self.truth_value(1,)) self.assertEqual( - __, + 'true stuff', self.truth_value("Python is named after Monty Python")) - self.assertEqual(__, self.truth_value(' ')) + self.assertEqual('true stuff', self.truth_value(' ')) diff --git a/python2/koans/about_true_and_false.pyc b/python2/koans/about_true_and_false.pyc new file mode 100644 index 000000000..127b65eba Binary files /dev/null and b/python2/koans/about_true_and_false.pyc differ diff --git a/python2/koans/about_tuples.py b/python2/koans/about_tuples.py index 5773c0ad6..263a3a01e 100644 --- a/python2/koans/about_tuples.py +++ b/python2/koans/about_tuples.py @@ -7,14 +7,14 @@ class AboutTuples(Koan): def test_creating_a_tuple(self): count_of_three = (1, 2, 5) - self.assertEqual(__, count_of_three[2]) + self.assertEqual(5, count_of_three[2]) def test_tuples_are_immutable_so_item_assignment_is_not_possible(self): count_of_three = (1, 2, 5) try: count_of_three[2] = "three" except TypeError as ex: - self.assertMatch(__, ex[0]) + self.assertMatch('tuple', ex[0]) def test_tuples_are_immutable_so_appending_is_not_possible(self): count_of_three = (1, 2, 5) @@ -25,7 +25,7 @@ def test_tuples_are_immutable_so_appending_is_not_possible(self): # Note, assertMatch() uses regular expression pattern matching, # so you don't have to copy the whole message. - self.assertMatch(__, ex[0]) + self.assertMatch('tuple', ex[0]) # Tuples are less flexible than lists, but faster. @@ -36,25 +36,25 @@ def test_tuples_can_only_be_changed_through_replacement(self): list_count.append("boom") count_of_three = tuple(list_count) - self.assertEqual(__, count_of_three) + self.assertEqual((1, 2, 5,"boom"), count_of_three) def test_tuples_of_one_look_peculiar(self): - self.assertEqual(__, (1).__class__.__name__) - self.assertEqual(__, (1,).__class__.__name__) - self.assertEqual(__, ("Hello comma!", )) + self.assertEqual('int', (1).__class__.__name__) + self.assertEqual('tuple', (1,).__class__.__name__) + self.assertEqual(('Hello comma!', ), ("Hello comma!", )) def test_tuple_constructor_can_be_surprising(self): - self.assertEqual(__, tuple("Surprise!")) + self.assertEqual(('S', 'u', 'r', 'p', 'r', 'i', 's', 'e', '!'), tuple("Surprise!")) def test_creating_empty_tuples(self): - self.assertEqual(__, ()) - self.assertEqual(__, tuple()) # Sometimes less confusing + self.assertEqual((), ()) + self.assertEqual((), tuple()) # Sometimes less confusing def test_tuples_can_be_embedded(self): lat = (37, 14, 6, 'N') lon = (115, 48, 40, 'W') place = ('Area 51', lat, lon) - self.assertEqual(__, place) + self.assertEqual(('Area 51', (37, 14, 6, 'N'), (115, 48, 40, 'W')), place) def test_tuples_are_good_for_representing_records(self): locations = [ @@ -66,5 +66,5 @@ def test_tuples_are_good_for_representing_records(self): ("Cthulhu", (26, 40, 1, 'N'), (70, 45, 7, 'W')) ) - self.assertEqual(__, locations[2][0]) - self.assertEqual(__, locations[0][1][2]) + self.assertEqual("Cthulhu", locations[2][0]) + self.assertEqual(15.56, locations[0][1][2]) diff --git a/python2/koans/about_tuples.pyc b/python2/koans/about_tuples.pyc new file mode 100644 index 000000000..44aba4fdd Binary files /dev/null and b/python2/koans/about_tuples.pyc differ diff --git a/python2/koans/about_with_statements.pyc b/python2/koans/about_with_statements.pyc new file mode 100644 index 000000000..e5ca57e12 Binary files /dev/null and b/python2/koans/about_with_statements.pyc differ diff --git a/python2/koans/another_local_module.pyc b/python2/koans/another_local_module.pyc new file mode 100644 index 000000000..7ed1397f2 Binary files /dev/null and b/python2/koans/another_local_module.pyc differ diff --git a/python2/koans/jims.pyc b/python2/koans/jims.pyc new file mode 100644 index 000000000..150a36c8b Binary files /dev/null and b/python2/koans/jims.pyc differ diff --git a/python2/koans/joes.pyc b/python2/koans/joes.pyc new file mode 100644 index 000000000..812596fee Binary files /dev/null and b/python2/koans/joes.pyc differ diff --git a/python2/koans/local_module_with_all_defined.pyc b/python2/koans/local_module_with_all_defined.pyc new file mode 100644 index 000000000..46d0f9622 Binary files /dev/null and b/python2/koans/local_module_with_all_defined.pyc differ diff --git a/python2/koans/triangle.pyc b/python2/koans/triangle.pyc new file mode 100644 index 000000000..c6c72479a Binary files /dev/null and b/python2/koans/triangle.pyc differ diff --git a/python2/libs/__init__.pyc b/python2/libs/__init__.pyc new file mode 100644 index 000000000..a667450e7 Binary files /dev/null and b/python2/libs/__init__.pyc differ diff --git a/python2/libs/colorama/__init__.pyc b/python2/libs/colorama/__init__.pyc new file mode 100644 index 000000000..3bae9bda2 Binary files /dev/null and b/python2/libs/colorama/__init__.pyc differ diff --git a/python2/libs/colorama/ansi.pyc b/python2/libs/colorama/ansi.pyc new file mode 100644 index 000000000..f57d3b781 Binary files /dev/null and b/python2/libs/colorama/ansi.pyc differ diff --git a/python2/libs/colorama/ansitowin32.pyc b/python2/libs/colorama/ansitowin32.pyc new file mode 100644 index 000000000..c1221f643 Binary files /dev/null and b/python2/libs/colorama/ansitowin32.pyc differ diff --git a/python2/libs/colorama/initialise.pyc b/python2/libs/colorama/initialise.pyc new file mode 100644 index 000000000..301c8908a Binary files /dev/null and b/python2/libs/colorama/initialise.pyc differ diff --git a/python2/libs/colorama/win32.pyc b/python2/libs/colorama/win32.pyc new file mode 100644 index 000000000..c752f721f Binary files /dev/null and b/python2/libs/colorama/win32.pyc differ diff --git a/python2/libs/colorama/winterm.pyc b/python2/libs/colorama/winterm.pyc new file mode 100644 index 000000000..39d2e0197 Binary files /dev/null and b/python2/libs/colorama/winterm.pyc differ diff --git a/python2/runner/__init__.pyc b/python2/runner/__init__.pyc new file mode 100644 index 000000000..e7f1cf6a4 Binary files /dev/null and b/python2/runner/__init__.pyc differ diff --git a/python2/runner/helper.pyc b/python2/runner/helper.pyc new file mode 100644 index 000000000..35c15643d Binary files /dev/null and b/python2/runner/helper.pyc differ diff --git a/python2/runner/koan.pyc b/python2/runner/koan.pyc new file mode 100644 index 000000000..d3c96cf52 Binary files /dev/null and b/python2/runner/koan.pyc differ diff --git a/python2/runner/mockable_test_result.pyc b/python2/runner/mockable_test_result.pyc new file mode 100644 index 000000000..51e8645bd Binary files /dev/null and b/python2/runner/mockable_test_result.pyc differ diff --git a/python2/runner/mountain.pyc b/python2/runner/mountain.pyc new file mode 100644 index 000000000..dfdac3f53 Binary files /dev/null and b/python2/runner/mountain.pyc differ diff --git a/python2/runner/path_to_enlightenment.pyc b/python2/runner/path_to_enlightenment.pyc new file mode 100644 index 000000000..7143029d9 Binary files /dev/null and b/python2/runner/path_to_enlightenment.pyc differ diff --git a/python2/runner/sensei.pyc b/python2/runner/sensei.pyc new file mode 100644 index 000000000..117badc71 Binary files /dev/null and b/python2/runner/sensei.pyc differ diff --git a/python2/runner/writeln_decorator.pyc b/python2/runner/writeln_decorator.pyc new file mode 100644 index 000000000..e134d69fc Binary files /dev/null and b/python2/runner/writeln_decorator.pyc differ