From 6229c1c605589a34d603c73a7cc94e6668bb6411 Mon Sep 17 00:00:00 2001 From: Chong Kim Date: Wed, 2 Sep 2015 16:02:06 -0400 Subject: [PATCH] Add sniffer support --- README.rst | 31 +++++++++++++++++++++++++++++++ python2/scent.py | 12 ++++++++++++ python3/scent.py | 12 ++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 python2/scent.py create mode 100644 python3/scent.py diff --git a/README.rst b/README.rst index 1c7ef631d..890ebcbbc 100644 --- a/README.rst +++ b/README.rst @@ -124,6 +124,37 @@ fire up the command line, recreate the scenario and run queries: .. image:: http://i442.photobucket.com/albums/qq150/gregmalcolm/DebuggingPython.png +Sniffer Support +--------------- + +Sniffer allows you to run the tests continuously. If you modify any files files +in the koans directory, it will rerun the tests. + +To set this up, you need to install sniffer:: + + $ pip install sniffer + +You should also run one of these libraries depending on your system. This will +automatically trigger sniffer when a file changes, otherwise sniffer will have +to poll to see if the files have changed. + +On Linux:: + + $ pip install pyinotify + +On Windows:: + + $ pip install pywin32 + +On Mac OS X:: + + $ pip install MacFSEvents + +Once it is set up, you just run:: + + $ sniffer + +Just modify one of the koans files and you'll see that the tests are triggered automatically. Sniffer is controlled by `scent.py` Getting the Most From the Koans ------------------------------- diff --git a/python2/scent.py b/python2/scent.py new file mode 100644 index 000000000..bba14fbd9 --- /dev/null +++ b/python2/scent.py @@ -0,0 +1,12 @@ +from sniffer.api import * +import os + +watch_paths = ['.', 'koans/'] + +@file_validator +def py_files(filename): + return filename.endswith('.py') and not os.path.basename(filename).startswith('.') + +@runnable +def execute_koans(*args): + os.system('python -B contemplate_koans.py') diff --git a/python3/scent.py b/python3/scent.py new file mode 100644 index 000000000..818506b10 --- /dev/null +++ b/python3/scent.py @@ -0,0 +1,12 @@ +from sniffer.api import * +import os + +watch_paths = ['.', 'koans/'] + +@file_validator +def py_files(filename): + return filename.endswith('.py') and not os.path.basename(filename).startswith('.') + +@runnable +def execute_koans(*args): + os.system('python3 -B contemplate_koans.py')