Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest-timeout does not work correctly with python2.7 #22

Closed
pytest-timeout-bot opened this issue Dec 19, 2017 · 6 comments
Closed

pytest-timeout does not work correctly with python2.7 #22

pytest-timeout-bot opened this issue Dec 19, 2017 · 6 comments
Labels
bug Something isn't working major

Comments

@pytest-timeout-bot
Copy link

Original report by Alexander Petrov (Bitbucket: alvipet, ).


Hi,

My bag is the same as https://bitbucket.org/pytest-dev/pytest-timeout/issues/21/timeout-does-not-seem-to-work-anymore-with

I have the next stack trace:

#!python

+++++++++++++++++++++++++++++++++++ Timeout ++++++++++++++++++++++++++++++++++++

~~~~~~~~~~~~~~~~~~~~~~~~ Stack of MainThread (2897892) ~~~~~~~~~~~~~~~~~~~~~~~~~
  File "d:\python27\Lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "d:\python27\Lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "d:\data\jenkins\venv\Scripts\pytest.exe\__main__.py", line 9, in <module>
    sys.exit(main())
  File "d:\data\jenkins\venv\lib\site-packages\_pytest\config.py", line 59, in main
    return config.hook.pytest_cmdline_main(config=config)
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "d:\data\jenkins\venv\lib\site-packages\_pytest\main.py", line 134, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "d:\data\jenkins\venv\lib\site-packages\_pytest\main.py", line 103, in wrap_session
    session.exitstatus = doit(config, session) or 0
  File "d:\data\jenkins\venv\lib\site-packages\_pytest\main.py", line 141, in _main
    config.hook.pytest_runtestloop(session=session)
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "d:\data\jenkins\venv\lib\site-packages\_pytest\main.py", line 164, in pytest_runtestloop
    item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "d:\data\jenkins\venv\lib\site-packages\_pytest\runner.py", line 62, in pytest_runtest_protocol
    runtestprotocol(item, nextitem=nextitem)
  File "d:\data\jenkins\venv\lib\site-packages\_pytest\runner.py", line 76, in runtestprotocol
    reports.append(call_and_report(item, "call", log))
  File "d:\data\jenkins\venv\lib\site-packages\_pytest\runner.py", line 155, in call_and_report
    call = call_runtest_hook(item, when, **kwds)
  File "d:\data\jenkins\venv\lib\site-packages\_pytest\runner.py", line 175, in call_runtest_hook
    return CallInfo(lambda: ihook(item=item, **kwds), when=when)
  File "d:\data\jenkins\venv\lib\site-packages\_pytest\runner.py", line 189, in __init__
    self.result = func()
  File "d:\data\jenkins\venv\lib\site-packages\_pytest\runner.py", line 175, in <lambda>
    return CallInfo(lambda: ihook(item=item, **kwds), when=when)
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "d:\data\jenkins\venv\lib\site-packages\_pytest\runner.py", line 106, in pytest_runtest_call
    item.runtest()
  File "d:\data\jenkins\venv\lib\site-packages\_pytest\python.py", line 1171, in runtest
    self.ihook.pytest_pyfunc_call(pyfuncitem=self)
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "d:\data\jenkins\venv\lib\site-packages\pluggy\callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "d:\data\jenkins\venv\lib\site-packages\_pytest\python.py", line 147, in pytest_pyfunc_call
    testfunction(**testargs)
  File "D:\data\jenkins\tmp\test_1.py", line 6, in test
    time.sleep(5)

+++++++++++++++++++++++++++++++++++ Timeout ++++++++++++++++++++++++++++++++++++

@pytest-timeout-bot
Copy link
Author

Original comment by Alexander Petrov (Bitbucket: alvipet, ).


I use:
python (2.7.13)
pytest-timeout (1.2.1)
pytest (3.3.1)

I run it all under virtualenv (15.1.0)

Thanks

@pytest-timeout-bot
Copy link
Author

Original comment by Floris Bruynooghe (Bitbucket: flub, GitHub: flub).


Hi,

Could you provide some more information please? What was the example you where running? What where you expecting to happen? From this traceback all I can see is that a timeout happended inside the time.sleep() call in your test, so I'm not sure what the problem is.

It's entirely possible I've missed something obvious and crucial though, hence please provide some more info.

Thanks

@pytest-timeout-bot
Copy link
Author

Original comment by Alexander Petrov (Bitbucket: alvipet, ).


Hi, Floris

Forgot to say that the test was running on Windows 10. I tried the simple test in the same configuration.

#!python

import pytest

@pytest.mark.timeout(2)
def test_01():
    for i in xrange(100000000):
        x = 2 * 2

@pytest.mark.timeout(2)
def test_02():
    for i in xrange(100):
        x = 2 * 2

Here is the output:

#!python


+++++++++++++++++++++++++++++++++++ Timeout ++++++++++++++++++++++++++++++++++++

~~~~~~~~~~~~~~~~~~~~~~~~~ Stack of MainThread (10232) ~~~~~~~~~~~~~~~~~~~~~~~~~~
  File "d:\python\python27\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "d:\python\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "D:\Python\Python27\Scripts\pytest.exe\__main__.py", line 9, in <module>
    sys.exit(main())
  File "d:\python\python27\lib\site-packages\_pytest\config.py", line 59, in main
    return config.hook.pytest_cmdline_main(config=config)
  File "d:\python\python27\lib\site-packages\pluggy\__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "d:\python\python27\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "d:\python\python27\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "d:\python\python27\lib\site-packages\pluggy\callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "d:\python\python27\lib\site-packages\_pytest\main.py", line 136, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "d:\python\python27\lib\site-packages\_pytest\main.py", line 105, in wrap_session
    session.exitstatus = doit(config, session) or 0
  File "d:\python\python27\lib\site-packages\_pytest\main.py", line 143, in _main
    config.hook.pytest_runtestloop(session=session)
  File "d:\python\python27\lib\site-packages\pluggy\__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "d:\python\python27\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "d:\python\python27\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "d:\python\python27\lib\site-packages\pluggy\callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "d:\python\python27\lib\site-packages\_pytest\main.py", line 166, in pytest_runtestloop
    item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
  File "d:\python\python27\lib\site-packages\pluggy\__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "d:\python\python27\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "d:\python\python27\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "d:\python\python27\lib\site-packages\pluggy\callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "d:\python\python27\lib\site-packages\_pytest\runner.py", line 62, in pytest_runtest_protocol
    runtestprotocol(item, nextitem=nextitem)
  File "d:\python\python27\lib\site-packages\_pytest\runner.py", line 76, in runtestprotocol
    reports.append(call_and_report(item, "call", log))
  File "d:\python\python27\lib\site-packages\_pytest\runner.py", line 155, in call_and_report
    call = call_runtest_hook(item, when, **kwds)
  File "d:\python\python27\lib\site-packages\_pytest\runner.py", line 175, in call_runtest_hook
    return CallInfo(lambda: ihook(item=item, **kwds), when=when)
  File "d:\python\python27\lib\site-packages\_pytest\runner.py", line 189, in __init__
    self.result = func()
  File "d:\python\python27\lib\site-packages\_pytest\runner.py", line 175, in <lambda>
    return CallInfo(lambda: ihook(item=item, **kwds), when=when)
  File "d:\python\python27\lib\site-packages\pluggy\__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "d:\python\python27\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "d:\python\python27\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "d:\python\python27\lib\site-packages\pluggy\callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "d:\python\python27\lib\site-packages\_pytest\runner.py", line 106, in pytest_runtest_call
    item.runtest()
  File "d:\python\python27\lib\site-packages\_pytest\python.py", line 1171, in runtest
    self.ihook.pytest_pyfunc_call(pyfuncitem=self)
  File "d:\python\python27\lib\site-packages\pluggy\__init__.py", line 617, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "d:\python\python27\lib\site-packages\pluggy\__init__.py", line 222, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "d:\python\python27\lib\site-packages\pluggy\__init__.py", line 216, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "d:\python\python27\lib\site-packages\pluggy\callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "d:\python\python27\lib\site-packages\_pytest\python.py", line 147, in pytest_pyfunc_call
    testfunction(**testargs)
  File "D:\data\dev\jopin\TMP\test_01.py", line 6, in test_01
    x = 2 * 2

+++++++++++++++++++++++++++++++++++ Timeout ++++++++++++++++++++++++++++++++++++

@pytest-timeout-bot
Copy link
Author

Original comment by Floris Bruynooghe (Bitbucket: flub, GitHub: flub).


Hi,

The first test is timing out and then execution is terminated. It looks to me as it's doing exactly what pytest-timeout is designed to do.

You still didn't say what you expected to happen in your test case and why? I'm honestly not seeing the issue here.

@pytest-timeout-bot
Copy link
Author

Original comment by Alexander Petrov (Bitbucket: alvipet, ).


Hi,
You are right. The first test is terminated, but I can't get xunit file as test results after this command:

#!python

pytest -v --junit-xml=log.xml

@pytest-timeout-bot
Copy link
Author

Original comment by Floris Bruynooghe (Bitbucket: flub, GitHub: flub).


Sure, that's correct. See https://bitbucket.org/pytest-dev/pytest-timeout/src/03c23b4e46254f87cb3bb642bf3d450a5c59e731/README?at=default&fileviewer=file-view-default#README-100 where this is described.

@pytest-timeout-bot pytest-timeout-bot added major bug Something isn't working labels Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working major
Projects
None yet
Development

No branches or pull requests

1 participant