1 new commit in pytest:

https://bitbucket.org/hpk42/pytest/changeset/67adc7327ef3/
changeset:   67adc7327ef3
user:        hpk42
date:        2011-11-06 16:40:17
summary:     fix FD leakage during pytest's own test run and add "--lsof" 
option to tox default test runs.

the leakage came down to a problematic bit of the stdlib logging module: it 
takes ownerships of stdout/stderr making it hard for pytest to implement clean 
capturing.  The current work around is to add some extra code in the setup 
machinery of pytest's own tests which actually closes sub-FDs.
affected #:  6 files

diff -r bc2f63120b354025a3de44a73ad1d8bd003a04c3 -r 
67adc7327ef35aa3bafd4d423b99eda72e39faa3 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 Changes between 2.1.3 and [next version]
 ----------------------------------------
 
+- fix pytest's own test suite to not leak FDs 
 - fix issue83: link to generated funcarg list
 - fix issue74: pyarg module names are now checked against imp.find_module 
false positives
 


diff -r bc2f63120b354025a3de44a73ad1d8bd003a04c3 -r 
67adc7327ef35aa3bafd4d423b99eda72e39faa3 _pytest/__init__.py
--- a/_pytest/__init__.py
+++ b/_pytest/__init__.py
@@ -1,2 +1,2 @@
 #
-__version__ = '2.1.3'
+__version__ = '2.1.4.dev1'


diff -r bc2f63120b354025a3de44a73ad1d8bd003a04c3 -r 
67adc7327ef35aa3bafd4d423b99eda72e39faa3 _pytest/pytester.py
--- a/_pytest/pytester.py
+++ b/_pytest/pytester.py
@@ -402,6 +402,15 @@
         config.pluginmanager.do_configure(config)
         self.request.addfinalizer(lambda:
             config.pluginmanager.do_unconfigure(config))
+        # XXX we need to additionally reset FDs to prevent pen FDs
+        # during our test suite. see also capture.py's unconfigure XXX
+        # comment about logging
+        def finalize_capman():
+            capman = config.pluginmanager.getplugin('capturemanager')
+            while capman._method2capture:
+                name, cap = capman._method2capture.popitem()
+                cap.reset()
+        self.request.addfinalizer(finalize_capman)
         return config
 
     def getitem(self,  source, funcname="test_func"):


diff -r bc2f63120b354025a3de44a73ad1d8bd003a04c3 -r 
67adc7327ef35aa3bafd4d423b99eda72e39faa3 setup.py
--- a/setup.py
+++ b/setup.py
@@ -24,7 +24,7 @@
         name='pytest',
         description='py.test: simple powerful testing with Python',
         long_description = long_description,
-        version='2.1.3',
+        version='2.1.4.dev1',
         url='http://pytest.org',
         license='MIT license',
         platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],


diff -r bc2f63120b354025a3de44a73ad1d8bd003a04c3 -r 
67adc7327ef35aa3bafd4d423b99eda72e39faa3 testing/conftest.py
--- a/testing/conftest.py
+++ b/testing/conftest.py
@@ -35,7 +35,7 @@
     __multicall__.execute()
     out2 = py.process.cmdexec("lsof -p %d" % pid)
     len2 = getopenfiles(out2)
-    assert len2 < config._numfiles + 7, out2
+    assert len2 < config._numfiles + 15, out2
 
 
 def pytest_runtest_setup(item):


diff -r bc2f63120b354025a3de44a73ad1d8bd003a04c3 -r 
67adc7327ef35aa3bafd4d423b99eda72e39faa3 tox.ini
--- a/tox.ini
+++ b/tox.ini
@@ -8,7 +8,7 @@
 
 [testenv]
 changedir=testing
-commands= py.test -rfsxX --junitxml={envlogdir}/junit-{envname}.xml []
+commands= py.test --lsof -rfsxX --junitxml={envlogdir}/junit-{envname}.xml []
 deps=
     :pypi:pexpect
     :pypi:nose

Repository URL: https://bitbucket.org/hpk42/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
py-svn mailing list
py-svn@codespeak.net
http://codespeak.net/mailman/listinfo/py-svn

Reply via email to