@@ -32,10 +32,14 @@ language by making tests pass.
32
32
33
33
Most tests are *fixed * by filling the missing parts of assert functions. Eg:
34
34
35
+ .. code-block :: python
36
+
35
37
self .assertEqual(__, 1 + 2 )
36
38
37
39
which can be fixed by replacing the __ part with the appropriate code:
38
40
41
+ .. code-block :: python
42
+
39
43
self .assertEqual(3 , 1 + 2 )
40
44
41
45
Occasionally you will encounter some failing tests that are already filled out.
@@ -50,11 +54,11 @@ a taste of Test Driven Development (TDD).
50
54
Downloading Python Koans
51
55
------------------------
52
56
53
- Python Koans is available through git on Github :
57
+ Python Koans is available on GitHub :
54
58
55
- http ://github.com/gregmalcolm/python_koans
59
+ * https ://github.com/gregmalcolm/python_koans
56
60
57
- Either site will allow you to download the source as a zip/gz/bz2.
61
+ You can clone with Git or download the source as a zip/gz/bz2.
58
62
59
63
60
64
Installing Python Koans
@@ -63,25 +67,25 @@ Installing Python Koans
63
67
Aside from downloading or checking out the latest version of Python Koans, you
64
68
need to install the Python interpreter.
65
69
66
- At this time of writing, we support Python3 . The policy is to try to keep
70
+ At this time of writing, we support Python 3 . The policy is to try to keep
67
71
current with the latest production version.
68
72
69
73
You should be able to work with newer Python versions, but older ones will
70
74
likely give you problems.
71
75
72
76
You can download Python from here:
73
77
74
- http ://www.python.org/download
78
+ * https ://www.python.org/downloads/
75
79
76
80
After installing Python make sure the folder containing the python executable
77
81
is in the system path. In other words, you need to be able to run Python from a
78
- command console. It will either be `python3 ` or for windows it will be `python.exe `.
82
+ command console. It will either be `` python3 `` or for Windows it will be `` python.exe ` `.
79
83
80
84
If you have problems, this may help:
81
85
82
- http ://www.python.org/about/gettingstarted
86
+ * https ://www.python.org/about/gettingstarted/
83
87
84
- Windows users may also want to update the line in the batch file `run.bat ` to
88
+ Windows users may also want to update the line in the batch file `` run.bat ` ` to
85
89
set the python path::
86
90
87
91
SET PYTHON_PATH=C:\Python39
@@ -92,19 +96,23 @@ Getting Started
92
96
93
97
Jake Hebbert has created a couple of screencasts available here:
94
98
95
- http ://www.youtube.com/watch?v=e2WXgXEjbHY&list=PL5Up_u-XkWgNcunP_UrTJG_3EXgbK2BQJ&index=1
99
+ https ://www.youtube.com/watch?v=e2WXgXEjbHY&list=PL5Up_u-XkWgNcunP_UrTJG_3EXgbK2BQJ&index=1
96
100
97
101
Or if you prefer to read:
98
102
99
- From a \* nix terminal or windows command prompt run::
103
+ From a \* nix terminal or Windows command prompt run::
104
+
105
+ .. code-block :: sh
100
106
101
107
python contemplate_koans.py
102
108
103
- or::
109
+ or:
110
+
111
+ .. code-block :: sh
104
112
105
113
python3 contemplate_koans.py
106
114
107
- In my case I'm using Python 3 with windows , so I fire up my command
115
+ In my case I'm using Python 3 with Windows , so I fire up my command
108
116
shell (cmd.exe) and run this:
109
117
110
118
.. image :: https://user-images.githubusercontent.com/2614930/28401747-f723ff00-6cd0-11e7-9b9a-a6993b753cf6.png
@@ -114,11 +122,13 @@ Apparently a test failed::
114
122
AssertionError: False is not True
115
123
116
124
It also tells me exactly where the problem is, it's an assert on line 12
117
- of .\\ koans\\ about_asserts.py. This one is easy, just change False to True to
125
+ of `` .\\koans\\about_asserts.py `` . This one is easy, just change `` False `` to `` True `` to
118
126
make the test pass.
119
127
120
128
Sooner or later you will likely encounter tests where you are not sure what the
121
- expected value should be. For example::
129
+ expected value should be. For example:
130
+
131
+ .. code-block :: python
122
132
123
133
class Dog :
124
134
pass
@@ -138,40 +148,51 @@ Sniffer Support
138
148
Sniffer allows you to run the tests continuously. If you modify any files files
139
149
in the koans directory, it will rerun the tests.
140
150
141
- To set this up, you need to install sniffer::
151
+ To set this up, you need to install sniffer:
152
+
153
+ .. code-block :: sh
142
154
143
- $ pip install sniffer
155
+ python3 -m pip install sniffer
144
156
145
157
You should also run one of these libraries depending on your system. This will
146
158
automatically trigger sniffer when a file changes, otherwise sniffer will have
147
159
to poll to see if the files have changed.
148
160
149
- On Linux::
161
+ On Linux:
162
+
163
+ .. code-block :: sh
150
164
151
- $ pip install pyinotify
165
+ python3 -m pip install pyinotify
152
166
153
- On Windows::
167
+ On Windows:
154
168
155
- $ pip install pywin32
169
+ .. code-block :: sh
170
+
171
+ python3 -m pip install pywin32
156
172
157
173
Also available here:
158
174
159
175
https://github.com/mhammond/pywin32/releases
160
176
161
- On Mac OS X::
177
+ On macOS:
178
+
179
+ .. code-block :: sh
180
+
181
+ python3 -m pip install MacFSEvents
162
182
163
- $ pip install MacFSEvents
183
+ Once it is set up, you just run:
164
184
165
- Once it is set up, you just run::
185
+ .. code-block :: sh
166
186
167
- $ sniffer
187
+ sniffer
168
188
169
- Just modify one of the koans files and you'll see that the tests are triggered automatically. Sniffer is controlled by `scent.py `
189
+ Just modify one of the koans files and you'll see that the tests are triggered
190
+ automatically. Sniffer is controlled by ``scent.py ``.
170
191
171
192
Getting the Most From the Koans
172
193
-------------------------------
173
194
174
- Quoting the Ruby Koans instructions::
195
+ Quoting the Ruby Koans instructions:
175
196
176
197
"In test-driven development the mantra has always been, red, green,
177
198
refactor. Write a failing test and run it (red), make the test pass
@@ -182,28 +203,15 @@ Quoting the Ruby Koans instructions::
182
203
and improve the code to better communicate its intent (refactor)."
183
204
184
205
185
- Content
186
- -------
187
-
188
- The Python Koans is a made up of about 2/3 Ruby Koans ported material and 1/3
189
- Python specific tests. The content ported from Ruby Koans includes all the
190
- assignment projects.
191
-
192
- Content for Python 3 is a little different to the Python 2 flavor due to big
193
- changes between the two different versions of the language. For example, in
194
- the Python 2 variant the differences between old and new style classes are
195
- covered. This loses relevance in in the Python 3 version, but there are some
196
- extra tests covering new functionality.
197
-
198
206
199
207
Finding More Koan Projects
200
208
--------------------------
201
209
202
210
There are number of other great Koan projects out there for various languages
203
- and frameworks. Most of them can be found in github . Also there is a little
204
- koans activity on bitbucket .
211
+ and frameworks. Most of them can be found in GitHub . Also there is a little
212
+ koans activity on Bitbucket .
205
213
206
- * Github koan projects:
214
+ * GitHub koan projects:
207
215
https://github.com/search?q=koans&ref=cmdform
208
216
209
217
* Bitbucket koan projects:
@@ -228,7 +236,7 @@ Also thanks to everyone who has contributed to Python Koans! I got a great
228
236
headstart by taking over a code base initiated by the combined Mikes of
229
237
FPIP. So here's a little plug for their very cool Python podcast:
230
238
231
- http ://frompythonimportpodcast.com/
239
+ * https ://www. frompythonimportpodcast.com/
232
240
233
241
A big thanks also to Mike Pirnat @pirnat and Kevin Chase @kjc have pitched in
234
242
as co-maintainers at various times
0 commit comments