Giter Club home page Giter Club logo

Comments (7)

pablogsal avatar pablogsal commented on July 28, 2024

Will take a look at this soon

from pytest-pystack.

pablogsal avatar pablogsal commented on July 28, 2024

Hummm, I cannot reproduce this. I am checking with this test file:

import pytest
import time

pytest_plugins = 'pytester'


def test_make_napari_viewer(pytester):
    """Make sure that our make_napari_viewer plugin works."""

    # create a temporary pytest test file
    pytester.makepyfile(
        """
            import time
            time.sleep(100)
            assert 1 == 2

    """
    )
    # run all tests with pytest
    result = pytester.runpytest()

    # check that all 1 test passed
    result.assert_outcomes(passed=1)

And running python -m pytest the_file.py --pystack-threshold=2 -vv work correctly as expected (pystack prints output after 2 seconds):

...
    (Python) File "/venv/lib/python3.10/site-packages/pluggy/_result.py", line 61, in from_call
        result = func()
    (Python) File "/venv/lib/python3.10/site-packages/pluggy/_manager.py", line 470, in <lambda>
        lambda: oldcall(hook_name, hook_impls, caller_kwargs, firstresult)
    (Python) File "/venv/lib/python3.10/site-packages/pluggy/_callers.py", line 102, in _multicall
        res = hook_impl.function(*args)
    (Python) File "/venv/lib/python3.10/site-packages/_pytest/runner.py", line 390, in pytest_make_collect_report
        call = CallInfo.from_call(collect, "collect")
    (Python) File "/venv/lib/python3.10/site-packages/_pytest/runner.py", line 340, in from_call
        result: Optional[TResult] = func()
    (Python) File "/venv/lib/python3.10/site-packages/_pytest/runner.py", line 388, in collect
        return list(collector.collect())
    (Python) File "/venv/lib/python3.10/site-packages/_pytest/python.py", line 576, in collect
        self._register_setup_module_fixture()
    (Python) File "/venv/lib/python3.10/site-packages/_pytest/python.py", line 589, in _register_setup_module_fixture
        self.obj, ("setUpModule", "setup_module")
    (Python) File "/venv/lib/python3.10/site-packages/_pytest/python.py", line 315, in obj
        self._obj = obj = self._getobj()
    (Python) File "/venv/lib/python3.10/site-packages/_pytest/python.py", line 573, in _getobj
        return importtestmodule(self.path, self.config)
    (Python) File "/venv/lib/python3.10/site-packages/_pytest/python.py", line 520, in importtestmodule
        mod = import_path(
    (Python) File "/venv/lib/python3.10/site-packages/_pytest/pathlib.py", line 584, in import_path
        importlib.import_module(module_name)
    (Python) File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
    (Python) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
    (Python) File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
    (Python) File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
    (Python) File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
    (Python) File "/venv/lib/python3.10/site-packages/_pytest/assertion/rewrite.py", line 178, in exec_module
        exec(co, module.__dict__)
    (Python) File "/tmp/pytest-of-root/pytest-26/test_make_napari_viewer0/test_make_napari_viewer.py", line 2, in <module>
        time.sleep(100)
``

from pytest-pystack.

Czaki avatar Czaki commented on July 28, 2024

Your example does not contain a test in the created file. Try this one:

import pytest
import time

pytest_plugins = 'pytester'


def test_make_napari_viewer(pytester):
    """Make sure that our make_napari_viewer plugin works."""

    # create a temporary pytest test file
    pytester.makepyfile(
        """
            import time
            
            def test_sleep():
                time.sleep(1)
                assert 1 == 2

    """
    )
    # run all tests with pytest
    result = pytester.runpytest()

    # check that all 1 test passed
    result.assert_outcomes(passed=1)

from pytest-pystack.

Czaki avatar Czaki commented on July 28, 2024

@pablogsal Any update?

from pytest-pystack.

pablogsal avatar pablogsal commented on July 28, 2024

I could reproduce with this example but with Python 3.13 beta 1 soon I cannot prioritise this currently as I need to attend other projects. Maybe @gusmonod can take a look

Otherwise if you want to give it a go we can take a PR :)

from pytest-pystack.

pablogsal avatar pablogsal commented on July 28, 2024

Oh, actually I haven't realised you opened a PR here:

#11

Can you add a test for this and we can merge it?

from pytest-pystack.

Czaki avatar Czaki commented on July 28, 2024

Added test

from pytest-pystack.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.