Skip to content

Commit 4366b50

Browse files
Fixes trailing whitespace
1 parent 49b6ed9 commit 4366b50

File tree

84 files changed

+1008
-1014
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1008
-1014
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ notifications:
1010

1111
# Some other koans (see runner/sensei.py or "ls koans" to see the light):
1212
#
13-
# about_none about_lists about_list_assignments about_dictionaries
14-
# about_strings about_tuples about_methods about_control_statements
13+
# about_none about_lists about_list_assignments about_dictionaries
14+
# about_strings about_tuples about_methods about_control_statements
1515
# about_true_and_false about_sets ...

Contributor Notes.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Running a whole test case:
99
$ python contemplate_koans.py about_strings
1010
or
1111
$ python3 contemplate_koans.py about_strings
12-
12+
1313
Running a single test:
1414

1515
$ python contemplate_koans.py about_strings.AboutStrings.test_triple_quoted_strings_need_less_escaping

README.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Python Koans is a port of Edgecase's "Ruby Koans".
66

77
.. image:: http://i442.photobucket.com/albums/qq150/gregmalcolm/PythonKoansScreenshot.png
88

9-
Python Koans is an interactive tutorial for learning Python by making tests pass.
9+
Python Koans is an interactive tutorial for learning Python by making tests pass.
1010

1111
Most tests are 'fixed' by filling the missing parts of assert functions. Eg:
1212

@@ -40,7 +40,7 @@ Installing Python Koans
4040

4141
Aside from downloading or checking out the latest version of Python Koans, all you need to install is Python.
4242

43-
At this time of writing there are two versions of the koans, one for use with Python 2.6 and one for Python 3.1. You should be able to work with newer Python versions, but older ones will likely give you problems.
43+
At this time of writing there are two versions of the koans, one for use with Python 2.6 and one for Python 3.1. You should be able to work with newer Python versions, but older ones will likely give you problems.
4444

4545
You can download Python from here:
4646

@@ -99,11 +99,11 @@ Getting the Most From the Koans
9999

100100
Quoting the Ruby Koans instructions::
101101

102-
"In test-driven development the mantra has always been, red, green,
102+
"In test-driven development the mantra has always been, red, green,
103103
refactor. Write a failing test and run it (red), make the test pass
104104
(green), then refactor it (that is look at the code and see if you
105105
can make it any better. In this case you will need to run the koan
106-
and see it fail (red), make the test pass (green), then take a
106+
and see it fail (red), make the test pass (green), then take a
107107
moment and reflect upon the test to see what it is teaching you
108108
and improve the code to better communicate its intent (refactor)."
109109

python2/_runner_tests.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ def suite():
1717

1818
if __name__ == '__main__':
1919
unittest.TextTestRunner(verbosity=2).run(suite())
20-

python2/contemplate_koans.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import sys
1515

1616

17-
if __name__ == '__main__':
17+
if __name__ == '__main__':
1818
if sys.version_info >= (3, 0):
1919
print("\nThis is the Python 2 version of Python Koans, but you are " +
2020
"running it with Python 3 or newer!\n\n"
@@ -31,7 +31,7 @@
3131
"to work!\n\n" +
3232
"But lets see how far we get...\n" +
3333
"********************************************************\n")
34-
34+
3535
from runner.mountain import Mountain
3636

3737
Mountain().walk_the_path(sys.argv)

python2/koans/about_decorating_with_classes.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ def test_partial_that_wrappers_no_args(self):
1919
the partial.
2020
"""
2121
max = functools.partial(self.maximum)
22-
22+
2323
self.assertEqual(__, max(7, 23))
2424
self.assertEqual(__, max(10, -10))
25-
25+
2626
def test_partial_that_wrappers_first_arg(self):
2727
max0 = functools.partial(self.maximum, 0)
2828

@@ -41,10 +41,10 @@ def test_partial_that_wrappers_all_args(self):
4141
class doubleit(object):
4242
def __init__(self, fn):
4343
self.fn = fn
44-
44+
4545
def __call__(self, *args):
4646
return self.fn(*args) + ', ' + self.fn(*args)
47-
47+
4848
def __get__(self, obj, cls=None):
4949
if not obj:
5050
# Decorating an unbound function
@@ -56,15 +56,15 @@ def __get__(self, obj, cls=None):
5656
@doubleit
5757
def foo(self):
5858
return "foo"
59-
59+
6060
@doubleit
6161
def parrot(self, text):
6262
return text.upper()
63-
63+
6464
def test_decorator_with_no_arguments(self):
6565
# To clarify: the decorator above the function has no arguments, even
6666
# if the decorated function does
67-
67+
6868
self.assertEqual(__, self.foo())
6969
self.assertEqual(__, self.parrot('pieces of eight'))
7070

@@ -77,25 +77,25 @@ def sound_check(self):
7777
def test_what_a_decorator_is_doing_to_a_function(self):
7878
#wrap the function with the decorator
7979
self.sound_check = self.doubleit(self.sound_check)
80-
80+
8181
self.assertEqual(__, self.sound_check())
8282

8383
# ------------------------------------------------------------------
8484

8585
class documenter(object):
8686
def __init__(self, *args):
8787
self.fn_doc = args[0]
88-
88+
8989
def __call__(self, fn):
9090
def decorated_function(*args):
9191
return fn(*args)
92-
92+
9393
if fn.__doc__:
9494
decorated_function.__doc__ = fn.__doc__ + ": " + self.fn_doc
9595
else:
9696
decorated_function.__doc__ = self.fn_doc
9797
return decorated_function
98-
98+
9999
@documenter("Increments a value by one. Kind of.")
100100
def count_badly(self, num):
101101
num += 1
@@ -117,7 +117,7 @@ def test_documentor_which_already_has_a_docstring(self):
117117
self.assertEqual(__, self.idler.__doc__)
118118

119119
# ------------------------------------------------------------------
120-
120+
121121
@documenter("DOH!")
122122
@doubleit
123123
@doubleit

python2/koans/about_decorating_with_functions.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@
33

44
from runner.koan import *
55

6-
6+
77
class AboutDecoratingWithFunctions(Koan):
88
def addcowbell(fn):
99
fn.wow_factor = 'COWBELL BABY!'
1010
return fn
11-
11+
1212
@addcowbell
1313
def mediocre_song(self):
1414
return "o/~ We all live in a broken submarine o/~"
15-
15+
1616
def test_decorators_can_modify_a_function(self):
1717
self.assertMatch(__, self.mediocre_song())
1818
self.assertEqual(__, self.mediocre_song.wow_factor)
19-
19+
2020
# ------------------------------------------------------------------
2121

2222
def xmltag(fn):
2323
def func(*args):
2424
return '<' + fn(*args) + '/>'
2525
return func
26-
26+
2727
@xmltag
2828
def render_tag(self, name):
2929
return name
30-
30+
3131
def test_decorators_can_change_a_function_output(self):
3232
self.assertEqual(__, self.render_tag('llama'))

python2/koans/about_deleting_objects.py

+20-20
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ def test_del_can_remove_slices(self):
99
lottery_nums = [4, 8, 15, 16, 23, 42]
1010
del lottery_nums[1]
1111
del lottery_nums[2:4]
12-
12+
1313
self.assertEqual(__, lottery_nums)
14-
14+
1515
def test_del_can_remove_entire_lists(self):
1616
lottery_nums = [4, 8, 15, 16, 23, 42]
1717
del lottery_nums
@@ -20,28 +20,28 @@ def test_del_can_remove_entire_lists(self):
2020
except Exception as e:
2121
pass
2222
self.assertMatch(__, e[0])
23-
23+
2424
# --------------------------------------------------------------------
25-
25+
2626
class ClosingSale(object):
2727
def __init__(self):
2828
self.hamsters = 7
2929
self.zebras = 84
30-
30+
3131
def cameras(self):
3232
return 34
33-
33+
3434
def toilet_brushes(self):
3535
return 48
36-
36+
3737
def jellies(self):
3838
return 5
39-
39+
4040
def test_del_can_remove_attributes(self):
4141
crazy_discounts = self.ClosingSale()
4242
del self.ClosingSale.toilet_brushes
4343
del crazy_discounts.hamsters
44-
44+
4545
try:
4646
still_available = crazy_discounts.toilet_brushes()
4747
except AttributeError as e:
@@ -51,7 +51,7 @@ def test_del_can_remove_attributes(self):
5151
still_available = crazy_discounts.hamsters
5252
except AttributeError as e:
5353
err_msg2 = e.args[0]
54-
54+
5555
self.assertMatch(__, err_msg1)
5656
self.assertMatch(__, err_msg2)
5757

@@ -60,7 +60,7 @@ def test_del_can_remove_attributes(self):
6060
class ClintEastwood(object):
6161
def __init__(self):
6262
self._name = None
63-
63+
6464
def get_name(self):
6565
try:
6666
return self._name
@@ -69,39 +69,39 @@ def get_name(self):
6969

7070
def set_name(self, name):
7171
self._name = name
72-
72+
7373
def del_name(self):
7474
del self._name
75-
75+
7676
name = property(get_name, set_name, del_name, \
7777
"Mr Eastwood's current alias")
78-
78+
7979
def test_del_works_with_properties(self):
8080
cowboy = self.ClintEastwood()
8181
cowboy.name = 'Senor Ninguno'
8282
self.assertEqual('Senor Ninguno', cowboy.name)
8383

8484
del cowboy.name
8585
self.assertEqual(__, cowboy.name)
86-
86+
8787
# --------------------------------------------------------------------
8888

8989
class Prisoner(object):
9090
def __init__(self):
9191
self._name = None
92-
92+
9393
@property
9494
def name(self):
9595
return self._name
9696

9797
@name.setter
9898
def name(self, name):
9999
self._name = name
100-
100+
101101
@name.deleter
102102
def name(self):
103103
self._name = 'Number Six'
104-
104+
105105
def test_another_way_to_make_a_deletable_property(self):
106106
citizen = self.Prisoner()
107107
citizen.name = "Patrick"
@@ -111,12 +111,12 @@ def test_another_way_to_make_a_deletable_property(self):
111111
self.assertEqual(__, citizen.name)
112112

113113
# --------------------------------------------------------------------
114-
114+
115115
class MoreOrganisedClosingSale(ClosingSale):
116116
def __init__(self):
117117
self.last_deletion = None
118118
super(AboutDeletingObjects.ClosingSale, self).__init__()
119-
119+
120120
def __delattr__(self, attr_name):
121121
self.last_deletion = attr_name
122122

python2/koans/about_dice_project.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
class DiceSet(object):
1010
def __init__(self):
1111
self._values = None
12-
12+
1313
@property
1414
def values(self):
1515
return self._values
16-
16+
1717
def roll(self, n):
1818
# Needs implementing!
1919
# Tip: random.randint(min, max) can be used to generate random numbers
@@ -27,45 +27,45 @@ def test_can_create_a_dice_set(self):
2727

2828
def test_rolling_the_dice_returns_a_set_of_integers_between_1_and_6(self):
2929
dice = DiceSet()
30-
30+
3131
dice.roll(5)
3232
self.assertTrue(isinstance(dice.values, list), "should be a list")
3333
self.assertEqual(5, len(dice.values))
3434
for value in dice.values:
3535
self.assertTrue(
3636
value >= 1 and value <= 6,
3737
"value " + str(value) + " must be between 1 and 6")
38-
38+
3939
def test_dice_values_do_not_change_unless_explicitly_rolled(self):
4040
dice = DiceSet()
4141
dice.roll(5)
4242
first_time = dice.values
4343
second_time = dice.values
4444
self.assertEqual(first_time, second_time)
45-
45+
4646
def test_dice_values_should_change_between_rolls(self):
4747
dice = DiceSet()
48-
48+
4949
dice.roll(5)
5050
first_time = dice.values
51-
51+
5252
dice.roll(5)
5353
second_time = dice.values
54-
54+
5555
self.assertNotEqual(first_time, second_time, \
5656
"Two rolls should not be equal")
57-
57+
5858
# THINK ABOUT IT:
5959
#
6060
# If the rolls are random, then it is possible (although not
6161
# likely) that two consecutive rolls are equal. What would be a
6262
# better way to test this?
63-
63+
6464
def test_you_can_roll_different_numbers_of_dice(self):
6565
dice = DiceSet()
66-
66+
6767
dice.roll(3)
6868
self.assertEqual(3, len(dice.values))
69-
69+
7070
dice.roll(1)
7171
self.assertEqual(1, len(dice.values))

0 commit comments

Comments
 (0)