holger krekel  committed 67adc73

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.

  • Participants
  • Parent commits bc2f631

Comments (0)

Files changed (6)

 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

File _pytest/

-__version__ = '2.1.3'
+__version__ = '2.1.4.dev1'

File _pytest/

+        # XXX we need to additionally reset FDs to prevent pen FDs
+        # during our test suite. see also'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"):
         description='py.test: simple powerful testing with Python',
         long_description = long_description,
-        version='2.1.3',
+        version='2.1.4.dev1',
         license='MIT license',
         platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],

File testing/

     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):
-commands= py.test -rfsxX --junitxml={envlogdir}/junit-{envname}.xml []
+commands= py.test --lsof -rfsxX --junitxml={envlogdir}/junit-{envname}.xml []