summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordianaclarke <diana.joan.clarke@gmail.com>2012-03-12 19:36:08 -0400
committerdianaclarke <diana.joan.clarke@gmail.com>2012-03-12 19:36:08 -0400
commit03dfcebb082caa29823262ed2137c29c06aa4349 (patch)
tree9444002e8431c61c1b239f93310cf03988fdd2bb
parentd67df81cbc1b4fafa967380b1f56ce5b33c604bc (diff)
downloadpyramid-03dfcebb082caa29823262ed2137c29c06aa4349.tar.gz
pyramid-03dfcebb082caa29823262ed2137c29c06aa4349.tar.bz2
pyramid-03dfcebb082caa29823262ed2137c29c06aa4349.zip
monkey patch atexit, since it seems to be gernerating this error in same
cases (but all the tests still pass) Ran 2083 tests in 8.913s OK Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "/mnt/hgfs/workspace/pyramid/pyramid/scripts/pserve.py", line 400, in _remove_pid_file current_pid = os.getpid() AttributeError: 'NoneType' object has no attribute 'getpid'
-rw-r--r--pyramid/tests/test_scripts/test_pserve.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/pyramid/tests/test_scripts/test_pserve.py b/pyramid/tests/test_scripts/test_pserve.py
index c1b91e3ae..6417791f3 100644
--- a/pyramid/tests/test_scripts/test_pserve.py
+++ b/pyramid/tests/test_scripts/test_pserve.py
@@ -1,3 +1,4 @@
+import atexit
import __builtin__
import os
import tempfile
@@ -97,7 +98,6 @@ class TestPServeCommand(unittest.TestCase):
def _remove_pid_unlink_exception(self, inst):
old_unlink = os.unlink
-
def fake_unlink(filename):
raise OSError('Some OSError - unlink')
@@ -109,12 +109,11 @@ class TestPServeCommand(unittest.TestCase):
def _remove_pid_unlink_and_write_exceptions(self, inst):
old_unlink = os.unlink
- old_open = __builtin__.open
-
def fake_unlink(filename):
raise OSError('Some OSError - unlink')
run_already = []
+ old_open = __builtin__.open
def fake_open(*args):
if not run_already:
run_already.append(True)
@@ -139,11 +138,21 @@ class TestPServeCommand(unittest.TestCase):
self.assertEqual(self.out_.getvalue(), msg)
def _assert_record_pid(self, verbosity, msg):
+ old_atexit = atexit.register
+ def fake_atexit(*args):
+ pass
+
self.pid_file = tempfile.mktemp()
pid = os.getpid()
inst = self._makeOne()
inst.verbose = verbosity
- inst.record_pid(self.pid_file)
+
+ try:
+ atexit.register = fake_atexit
+ inst.record_pid(self.pid_file)
+ finally:
+ atexit.register = old_atexit
+
msg = msg % (pid, self.pid_file) if msg else ''
self.assertEqual(self.out_.getvalue(), msg)
with open(self.pid_file) as f: