[TIP] py.test fails when called via nant with "ValueError: saved filedescriptor not valid, did you call start() twice?"

holger krekel holger at merlinux.eu
Tue Jan 29 08:51:48 PST 2013


Hi Berthold,


On Tue, Jan 29, 2013 at 17:23 +0100, Berthold Hoellmann wrote:
> 
> I try to add pytest to a larger Python library of mine. Main development
> system is Linux, but the software has to run on Windows also. We are
> using CC.NET as CI tool.
> 
> The software has a complex build system which is controlled by a
> Makefile. This Makefile system controls my tests also, so when i started
> to use pytest it was added to the make system. The make makes heavy use
> of UNIX tools and so it is run under CYGWIN under Windows.
> 
> For some of the tests specific environment variables have to be set. The
> system for setting environment variables in CC.NET does not ensure given
> case in the variable names so I had to add an nant script to ensure the
> correct environment variables are set for some of the tools.
> 
> And this nant system seems to case trouble for me. When I start the make
> command from out Windows Server 2008 R2 command line the tests are
> working, but when I use the NANT script, which in turn calls make I get
> errors from py.test:
> 
> makefile 
> 
> [exec] PYTHONPATH="D:/ContinuousIntegration/Builds/checkout/GLPy/build/lib;D:/ContinuousIntegration/Builds/checkout/GLPy/build/lib.win32-2.7;" python -tt -m pytest --ignore=../lib/gl/BSXF/create/get_sxf_structure.py --ignore=../lib/gl/Buckling/buckling.py --ignore=../lib/gl/Jinc/jinc_database.py --ignore=../lib/gl/Priefas/ReadPropForcesXML.py --ignore=../lib/gl/Vibration/amls/matrix/testColsArray.py --ignore=../lib/gl/Vibration/amls/test.py --ignore=../lib/gl/Vibration/lanczos/lan.py --ignore=../lib/gl/fevtk.py --ignore=../lib/gl/forcesum.py --ignore=../lib/gl/Vibration --ignore=../lib/gl/FastBEM --ignore=../lib/gl/AnsysInterface --ignore=../lib/gl/Simulation  \
>      [exec]   --doctest-modules ../lib/gl/
>      [exec] Traceback (most recent call last):
>      [exec]   File "C:\Program Files (x86)\GL Programs\GLPythonDist\Python27\lib\runpy.py", line 162, in _run_module_as_main
>      [exec]     "__main__", fname, loader, pkg_name)
>      [exec]   File "C:\Program Files (x86)\GL Programs\GLPythonDist\Python27\lib\runpy.py", line 72, in _run_code
>      [exec]     exec code in run_globals
>      [exec]   File "C:\Program Files (x86)\GL Programs\GLPythonDist\Python27\lib\site-packages\pytest.py", line 9, in <module>
>      [exec]     raise SystemExit(pytest.main())
>      [exec]   File "C:\Program Files (x86)\GL Programs\GLPythonDist\Python27\lib\site-packages\_pytest\core.py", line 473, in main
>      [exec]     config = _prepareconfig(args, plugins)
>      [exec]   File "C:\Program Files (x86)\GL Programs\GLPythonDist\Python27\lib\site-packages\_pytest\core.py", line 463, in _prepareconfig
>      [exec]     pluginmanager=_pluginmanager, args=args)
>      [exec]   File "C:\Program Files (x86)\GL Programs\GLPythonDist\Python27\lib\site-packages\_pytest\core.py", line 422, in __call__
>      [exec]     return self._docall(methods, kwargs)
>      [exec]   File "C:\Program Files (x86)\GL Programs\GLPythonDist\Python27\lib\site-packages\_pytest\core.py", line 433, in _docall
>      [exec]     res = mc.execute()
>      [exec]   File "C:\Program Files (x86)\GL Programs\GLPythonDist\Python27\lib\site-packages\_pytest\core.py", line 351, in execute
>      [exec]     res = method(**kwargs)
>      [exec]   File "C:\Program Files (x86)\GL Programs\GLPythonDist\Python27\lib\site-packages\_pytest\helpconfig.py", line 25, in pytest_cmdline_parse
>      [exec]     config = __multicall__.execute()
>      [exec]   File "C:\Program Files (x86)\GL Programs\GLPythonDist\Python27\lib\site-packages\_pytest\core.py", line 351, in execute
>      [exec]     res = method(**kwargs)
>      [exec]   File "C:\Program Files (x86)\GL Programs\GLPythonDist\Python27\lib\site-packages\_pytest\config.py", line 10, in pytest_cmdline_parse
>      [exec]     config.parse(args)
>      [exec]   File "C:\Program Files (x86)\GL Programs\GLPythonDist\Python27\lib\site-packages\_pytest\config.py", line 373, in parse
>      [exec]     self._preparse(args)
>      [exec]   File "C:\Program Files (x86)\GL Programs\GLPythonDist\Python27\lib\site-packages\_pytest\config.py", line 351, in _preparse
>      [exec]     self._setinitialconftest(args)
>      [exec]   File "C:\Program Files (x86)\GL Programs\GLPythonDist\Python27\lib\site-packages\_pytest\config.py", line 327, in _setinitialconftest
>      [exec]     capman.resumecapture()
>      [exec]   File "C:\Program Files (x86)\GL Programs\GLPythonDist\Python27\lib\site-packages\_pytest\capture.py", line 101, in resumecapture
>      [exec]     cap.startall()
>      [exec]   File "C:\Program Files (x86)\GL Programs\GLPythonDist\Python27\lib\site-packages\py\_io\capture.py", line 229, in startall
>      [exec]     self.in_.start()
>      [exec]   File "C:\Program Files (x86)\GL Programs\GLPythonDist\Python27\lib\site-packages\py\_io\capture.py", line 56, in start
>      [exec]     raise ValueError("saved filedescriptor not valid, "
>      [exec] ValueError: saved filedescriptor not valid, did you call start() twice?
> 
> First I thought of it as problem in one of my libraries, but the error
> also appears when I ignore all tests at the command line. I was not able
> to find information on this error that made sense for me. 

It's related to capturing stdout/stderr on the (default) filedescriptor
level but i am not sure what exactly is going on.   Does it work when
you add "--capture=sys" to the options?  This switched the capturing method
to intercepting sys.stdout/stderr at the python level, not touching
file descriptors. 

best,
holger


> What can I do to make this run?
> 
> pytest ist version 2.3.4
> 
> Thanks
> Berthold
> 
> -- 
>                             __   Address:
>                          G /  \ L Germanischer Lloyd SE
> phone: +49-40-36149-7374 -+----+- Brooktorkai 18
> fax  : +49-40-36149-7320   \__/   D-20457 Hamburg
> 
> 
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
> 



More information about the testing-in-python mailing list