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.
This commit is contained in:
holger krekel 2011-11-06 15:40:17 +00:00
parent 761a95e542
commit d4fe273b2f
6 changed files with 14 additions and 4 deletions

View File

@ -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

View File

@ -1,2 +1,2 @@
#
__version__ = '2.1.3'
__version__ = '2.1.4.dev1'

View File

@ -402,6 +402,15 @@ class TmpTestdir:
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"):

View File

@ -24,7 +24,7 @@ def main():
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'],

View File

@ -35,7 +35,7 @@ def pytest_unconfigure(config, __multicall__):
__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):

View File

@ -8,7 +8,7 @@ indexserver=
[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