Skip to content

Commit 1afb32d

Browse files
committed
Merge pull request gregmalcolm#118 from chongkim/add-sniffer-support
Add sniffer support
2 parents 838f41e + 6229c1c commit 1afb32d

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

README.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,37 @@ fire up the command line, recreate the scenario and run queries:
124124

125125
.. image:: http://i442.photobucket.com/albums/qq150/gregmalcolm/DebuggingPython.png
126126

127+
Sniffer Support
128+
---------------
129+
130+
Sniffer allows you to run the tests continuously. If you modify any files files
131+
in the koans directory, it will rerun the tests.
132+
133+
To set this up, you need to install sniffer::
134+
135+
$ pip install sniffer
136+
137+
You should also run one of these libraries depending on your system. This will
138+
automatically trigger sniffer when a file changes, otherwise sniffer will have
139+
to poll to see if the files have changed.
140+
141+
On Linux::
142+
143+
$ pip install pyinotify
144+
145+
On Windows::
146+
147+
$ pip install pywin32
148+
149+
On Mac OS X::
150+
151+
$ pip install MacFSEvents
152+
153+
Once it is set up, you just run::
154+
155+
$ sniffer
156+
157+
Just modify one of the koans files and you'll see that the tests are triggered automatically. Sniffer is controlled by `scent.py`
127158

128159
Getting the Most From the Koans
129160
-------------------------------

python2/scent.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from sniffer.api import *
2+
import os
3+
4+
watch_paths = ['.', 'koans/']
5+
6+
@file_validator
7+
def py_files(filename):
8+
return filename.endswith('.py') and not os.path.basename(filename).startswith('.')
9+
10+
@runnable
11+
def execute_koans(*args):
12+
os.system('python -B contemplate_koans.py')

python3/scent.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from sniffer.api import *
2+
import os
3+
4+
watch_paths = ['.', 'koans/']
5+
6+
@file_validator
7+
def py_files(filename):
8+
return filename.endswith('.py') and not os.path.basename(filename).startswith('.')
9+
10+
@runnable
11+
def execute_koans(*args):
12+
os.system('python3 -B contemplate_koans.py')

0 commit comments

Comments
 (0)