Skip to content
Browse files

Run doctests via nose

Move beanstalkd process management to a test support fixture.
  • Loading branch information...
1 parent 24ceb3b commit 4fab6d9fc4cafda650076d1be6a5c4f7870096a1 @earl committed Feb 28, 2012
View
6 .nose.cfg
@@ -0,0 +1,6 @@
+[nosetests]
+verbosity=3
+
+with-doctest=1
+doctest-extension=mkd
+doctest-fixtures=_fixtures
View
2 README.mkd
@@ -21,7 +21,7 @@ Usage
Here is a short example, to illustrate the flavor of beanstalkc:
>>> import beanstalkc
- >>> beanstalk = beanstalkc.Connection(host='localhost', port=11300)
+ >>> beanstalk = beanstalkc.Connection(host='localhost', port=14711)
>>> beanstalk.put('hey!')
1
>>> job = beanstalk.reserve()
View
1 README_fixtures.py
@@ -0,0 +1 @@
+from test.fixtures import setup, teardown
View
1 TUTORIAL_fixtures.py
@@ -0,0 +1 @@
+from test.fixtures import setup, teardown
View
11 beanstalkc.py
@@ -284,12 +284,5 @@ def stats(self):
if __name__ == '__main__':
- import doctest, os, signal
- try:
- pid = os.spawnlp(os.P_NOWAIT,
- 'beanstalkd',
- 'beanstalkd', '-l', '127.0.0.1', '-p', '14711')
- doctest.testfile('TUTORIAL.mkd')
- doctest.testfile('test/no-yaml.doctest')
- finally:
- os.kill(pid, signal.SIGTERM)
+ import nose
+ nose.main(argv=['nosetests', '-c', '.nose.cfg'])
View
0 test/__init__.py
No changes.
View
13 test/fixtures.py
@@ -0,0 +1,13 @@
+import os, signal, time
+
+_BEANSTALKD_PID = None
+
+def setup(module):
+ module._BEANSTALKD_PID = os.spawnlp(
+ os.P_NOWAIT,
+ 'beanstalkd',
+ 'beanstalkd', '-l', '127.0.0.1', '-p', '14711')
+ time.sleep(0.5) # Give beanstalkd some time to ready.
+
+def teardown(module):
+ os.kill(module._BEANSTALKD_PID, signal.SIGTERM)
View
0 test/no-yaml.doctest → test/no-yaml.mkd
File renamed without changes.
View
1 test/no-yaml_fixtures.py
@@ -0,0 +1 @@
+from fixtures import setup, teardown

0 comments on commit 4fab6d9

Please sign in to comment.
Something went wrong with that request. Please try again.