a plugin for py.test that changes the default look and feel of py.test (e.g. progressbar, show tests that fail instantly)

Overview

pytest-sugar

Build status Pypi version

pytest-sugar is a plugin for pytest that shows failures and errors instantly and shows a progress bar.

Demo

Requirements

You will need the following prerequisites in order to use pytest-sugar:

  • Python 2.7, 3.4 or newer
  • pytest 2.9.0 or newer
  • pytest-xdist 1.14 or above if you want the progress bar to work while running tests in parallel

Installation

To install pytest-sugar:

pip install pytest-sugar

Then run your tests with:

$ pytest

If you would like more detailed output (one test per line), then you may use the verbose option:

$ pytest --verbose

If you would like to run tests without pytest-sugar, use:

$ pytest -p no:sugar

Running on Windows

If you are seeing gibberish, you might want to try changing charset and fonts. See this comment for more details.

Comments
  • pytest-sugar is not working with pytest v5.4.0 (released on March 12th 2020)

    pytest-sugar is not working with pytest v5.4.0 (released on March 12th 2020)

    pytest-sugar is not working with pytest v5.4.0 (released on March 12th 2020)

    INTERNALERROR> Traceback (most recent call last):
    INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/_pytest/main.py", line 187, in wrap_session
    INTERNALERROR>     config._do_configure()
    INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/_pytest/config/__init__.py", line 820, in _do_configure
    INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
    INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pluggy/hooks.py", line 308, in call_historic
    INTERNALERROR>     res = self._hookexec(self, self.get_hookimpls(), kwargs)
    INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 93, in _hookexec
    INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
    INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 87, in <lambda>
    INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
    INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
    INTERNALERROR>     return outcome.get_result()
    INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    INTERNALERROR>     raise ex[1].with_traceback(ex[2])
    INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
    INTERNALERROR>     res = hook_impl.function(*args)
    INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pytest_sugar.py", line 176, in pytest_configure
    INTERNALERROR>     sugar_reporter = SugarTerminalReporter(standard_reporter)
    INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pytest_sugar.py", line 214, in __init__
    INTERNALERROR>     self.writer = self._tw
    INTERNALERROR> AttributeError: can't set attribute
    
    opened by MarcBoissonneault 22
  • SugarVerbose: Print more verbose testcase reports for all o…

    SugarVerbose: Print more verbose testcase reports for all o…

    …utcome

    Signed-off-by: Andras Mitzki [email protected]

    I have found that pytest-sugar can display each failed testcases which is a useful feature. For me it would be even better if it could display it for each pytest outcomes. The original idea came from the error outcomes which can happen in setup or teardown phases also and I would like to know when it happened. Maybe the option name (--sugar-verbose) is not the best, it is fine to change it.

    Update: The functionality from using "--sugar-verbose" arg has been changed to use "native" pytest arg: "-ra"

    Example to run this feature use the following execution:

    $ python3 -m pytest -ra t.py 
    

    Before

    Results (0.05s):
           5 passed
           3 failed
             - t.py:4 test_B
             - t.py:7 test_C
             - t.py:10 test_D
           1 error
    

    After

    Results (0.05s):
           5 passed
             - t.py:1 test_A (call)
             - t.py:18 test_E (call)
             - t.py:23 test_F[3+5-8] (call)
             - t.py:23 test_F[2+4-6] (call)
             - t.py:23 test_F[6*9-42] (call)
           3 failed
             - t.py:4 test_B (call)
             - t.py:7 test_C (call)
             - t.py:10 test_D (call)
           1 error
             - t.py:18 test_E (teardown)
    
    opened by mitzkia 18
  • AttributeError: 'NoneType' object has no attribute 'testscollected'

    AttributeError: 'NoneType' object has no attribute 'testscollected'

    Running some tests on circleci and I get the following exception (see full stacktrace below).

    When I don't install pytest-sugar, test runs fine.

    Oddly enough I cannot (yet) reproduce locally.

    Command used to run py.test

    py.test

    Output

    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/_pytest/main.py", line 185, in wrap_session
    INTERNALERROR>     session.exitstatus = doit(config, session) or 0
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/_pytest/main.py", line 225, in _main
    INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/hooks.py", line 284, in __call__
    INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/manager.py", line 67, in _hookexec
    INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/manager.py", line 61, in <lambda>
    INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 203, in _multicall
    INTERNALERROR>     gen.send(outcome)
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    INTERNALERROR>     raise ex[1].with_traceback(ex[2])
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
    INTERNALERROR>     res = hook_impl.function(*args)
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/_pytest/main.py", line 246, in pytest_runtestloop
    INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/hooks.py", line 284, in __call__
    INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/manager.py", line 67, in _hookexec
    INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/manager.py", line 61, in <lambda>
    INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
    INTERNALERROR>     return outcome.get_result()
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    INTERNALERROR>     raise ex[1].with_traceback(ex[2])
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
    INTERNALERROR>     res = hook_impl.function(*args)
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/_pytest/runner.py", line 78, in pytest_runtest_protocol
    INTERNALERROR>     item.ihook.pytest_runtest_logfinish(nodeid=item.nodeid, location=item.location)
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/hooks.py", line 284, in __call__
    INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/manager.py", line 67, in _hookexec
    INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/manager.py", line 61, in <lambda>
    INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
    INTERNALERROR>     return outcome.get_result()
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    INTERNALERROR>     raise ex[1].with_traceback(ex[2])
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
    INTERNALERROR>     res = hook_impl.function(*args)
    INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/_pytest/terminal.py", line 432, in pytest_runtest_logfinish
    INTERNALERROR>     len(self._progress_nodeids_reported) == self._session.testscollected
    INTERNALERROR> AttributeError: 'NoneType' object has no attribute 'testscollected'
    
    opened by djrobstep 17
  • Broken support for Python 3.6

    Broken support for Python 3.6

    This commit breaks python 3.6 compatibility due to termcolor 2 requiring >= python 3.7.

    • https://github.com/Teemu/pytest-sugar/pull/259
    • https://github.com/Teemu/pytest-sugar/commit/6b82c48c4cadefc6f26eed3662863292e1c77101

    And, seems you forgot to update tox.ini:

    • https://github.com/Teemu/pytest-sugar/blob/b42404819db5c09b9337dd1e3a7a95c5744c7e60/tox.ini#L12
    opened by xkszltl 15
  • Breaks when py is not installed

    Breaks when py is not installed

    pytest 7.2.0, released just now, makes py an optional dependency (https://docs.pytest.org/en/stable/changelog.html#pytest-7-2-0-2022-10-23), but pytest-sugar still relies on it, leading to a crash if py is not installed:

    INTERNALERROR> Traceback (most recent call last):
    INTERNALERROR>   File "/home/jelle/ans/venv3.9/lib/python3.9/site-packages/_pytest/main.py", line 268, in wrap_session
    INTERNALERROR>     config.hook.pytest_sessionstart(session=session)
    INTERNALERROR>   File "/home/jelle/ans/venv3.9/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
    INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
    INTERNALERROR>   File "/home/jelle/ans/venv3.9/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
    INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
    INTERNALERROR>   File "/home/jelle/ans/venv3.9/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
    INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
    INTERNALERROR>   File "/home/jelle/ans/venv3.9/lib/python3.9/site-packages/pluggy/callers.py", line 208, in _multicall
    INTERNALERROR>     return outcome.get_result()
    INTERNALERROR>   File "/home/jelle/ans/venv3.9/lib/python3.9/site-packages/pluggy/callers.py", line 80, in get_result
    INTERNALERROR>     raise ex[1].with_traceback(ex[2])
    INTERNALERROR>   File "/home/jelle/ans/venv3.9/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
    INTERNALERROR>     res = hook_impl.function(*args)
    INTERNALERROR>   File "/home/jelle/ans/venv3.9/lib/python3.9/site-packages/pytest_sugar.py", line 242, in pytest_sessionstart
    INTERNALERROR>     self._sessionstarttime = py.std.time.time()
    INTERNALERROR> AttributeError: module 'py' has no attribute 'std'
    

    (Invoking pytest in a env with pytest-sugar but not py installed.)

    opened by JelleZijlstra 15
  • Update to pytest 5.4.0 API

    Update to pytest 5.4.0 API

    This PR uses self.write() instead of self.writer.write() to follow new pytest 5.4.0 API and avoid using self.writer directly which has been deprecated.

    Closes https://github.com/Teemu/pytest-sugar/issues/187

    opened by GuillaumeFavelier 15
  • Cannot disable xdist when sugar is installed

    Cannot disable xdist when sugar is installed

    This bug report was originally posted at pytest-xdist's but it seems the fault is actually on sugar :) There may be some clues in this bug report though.

    Command used to run py.test

    pip install pytest pytest-xdist pytest-sugar
    pytest -p no:xdist test_foobar.py
    

    Test file

    def test_false(): assert False
    

    Output

    Test session starts (platform: linux, Python 3.6.1, pytest 3.1.0, pytest-sugar 0.8.0)
    rootdir: /home/eloi/pytest-xdist-test, inifile:
    plugins: xdist-1.16.0, sugar-0.8.0
    INTERNALERROR> Traceback (most recent call last):
    INTERNALERROR>   File "/home/eloi/pytest-xdist-test/env/lib/python3.6/site-packages/_pytest/main.py", line 105, in wrap_session
    INTERNALERROR>     session.exitstatus = doit(config, session) or 0
    INTERNALERROR>   File "/home/eloi/pytest-xdist-test/env/lib/python3.6/site-packages/_pytest/main.py", line 140, in _main
    INTERNALERROR>     config.hook.pytest_collection(session=session)
    INTERNALERROR>   File "/home/eloi/pytest-xdist-test/env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
    INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
    INTERNALERROR>   File "/home/eloi/pytest-xdist-test/env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
    INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
    INTERNALERROR>   File "/home/eloi/pytest-xdist-test/env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
    INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
    INTERNALERROR>   File "/home/eloi/pytest-xdist-test/env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
    INTERNALERROR>     res = hook_impl.function(*args)
    INTERNALERROR>   File "/home/eloi/pytest-xdist-test/env/lib/python3.6/site-packages/_pytest/main.py", line 150, in pytest_collection
    INTERNALERROR>     return session.perform_collect()
    INTERNALERROR>   File "/home/eloi/pytest-xdist-test/env/lib/python3.6/site-packages/_pytest/main.py", line 605, in perform_collect
    INTERNALERROR>     self.config.pluginmanager.check_pending()
    INTERNALERROR>   File "/home/eloi/pytest-xdist-test/env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 498, in check_pending
    INTERNALERROR>     (name, hookimpl.plugin))
    INTERNALERROR> _pytest.vendored_packages.pluggy.PluginValidationError: unknown hook 'pytest_xdist_node_collection_finished' in plugin <module 'pytest_sugar' (<_pytest.assertion.rewrite.AssertionRewritingHook object at 0x7f45f9176358>)>
    

    Thank you

    opened by azmeuk 14
  • Improvement suggestions

    Improvement suggestions

    Heyup. I really like pytest-sugar, but it misbehaves in small terminal windows with long test file paths. It also doesn't work with well my color theme (solarized), so I started looking at it and made some adjustments.

    Mainly:

    • using termcolor for much easier coloration and configuration
    • simplify the progressbar maths code
    • change the 's' for skipped tests to a circle
    • simplify the space filling logic of full_line
    • reduce the right margin to 0, so the blinking cursor is hidden

    Let me know whether you like any of the changes. I'd like to continue in this direction and add:

    • ~~configurable colors via config file~~ [update: now can be done with pytest-sugar.conf or ~/.pytest-sugar.conf]
    • ~~red progressbar / percentage, so it is immediately visible that there was at least one failure, even if it has scrolled out of view already~~ [update: added, percentage and failed progress bar sections could have the same color as the progress bar by default, so one has to enable it explicitly with a theme setting in the config]
    • ~~handling of long file paths, that reach into the progressbar / percentage, probably by shortening the path to ".../rest/of/path.py"~~ [update: also done now]
    opened by or 12
  • Maintenance and possible move to under pytest-dev org

    Maintenance and possible move to under pytest-dev org

    While I really LOVE pytest-sugar it saddens me to see it mainly unmaintained in the last 3 years. I am sure that sooner or later things will break and I would like to propose the following:

    • move the project under https://github.com/pytest-dev to make it more official plugin, and where there are others that could give hand if needed
    • add one or two more maintainers so they can at least review and merged incoming PRs before they get outdated
    question needswork 
    opened by ssbarnea 10
  • Print correct location for doctest failures

    Print correct location for doctest failures

    This PR extends the latest fix that prints '?' for line numbers of doctest failures and provides correct line number values

    With this PR for a file that looks like this:

    def foobar():
        """
        >>> foobar()
        """
        raise NotImplementedError
    
    

    it prints

    Test session starts (platform: linux, Python 3.6.1, pytest 3.0.6, pytest-sugar 0.8.0)
    rootdir: /home/immerrr/sources/pytest-sugar, inifile: 
    plugins: sugar-0.8.0
    
    
    ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― [doctest] doctestmod.foobar ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
    002 
    003     >>> foobar()
    UNEXPECTED EXCEPTION: NotImplementedError()
    Traceback (most recent call last):
    
      File "/home/immerrr/.conda/envs/pytest-sugar/lib/python3.6/doctest.py", line 1330, in __run
        compileflags, 1), test.globs)
    
      File "<doctest doctestmod.foobar[0]>", line 1, in <module>
    
      File "/home/immerrr/sources/pytest-sugar/doctestmod.py", line 5, in foobar
        raise NotImplementedError
    
    NotImplementedError
    
    /home/immerrr/sources/pytest-sugar/doctestmod.py:3: UnexpectedException
    
     doctestmod.py ⨯                                                                                                                                                                100% ██████████
    
    Results (0.03s):
           1 failed
             - doctestmod.py:3 [doctest] doctestmod.foobar
    
    
    opened by immerrr 10
  • Fix regression with pytest 5.4 and line number report for doctests

    Fix regression with pytest 5.4 and line number report for doctests

    Hi!

    While working on #194, I came across and fixed #134 as well. 👍

    • Fix line number report for doctests in pytest>=3.10
    • Fix compatibility with pytest 5.4

    Fix #194 Fix #134 Fix #180 Close pytest-dev/pytest#7287

    opened by nicoddemus 9
  • Print test name before result in verbose mode

    Print test name before result in verbose mode

    Without pytest-sugar, when running pytest in verbose mode, the name of the current test is printed immediately.

    This is very useful for long running tests since you know which test is hanging, and which test might be killed.

    However, with pytest-sugar, the name of the test is only printed when the test succeeds.

    I've provided an example of the code to reproduce this as well some minimal environment information.

    The current environment in question is running Python 3.9.

    Let me know if there is any more information you need to recreate the bug/"missing feature".

    Conda environment

    (mcam_dev) ✔ ~/Downloads
    09:13 $ mamba list pytest
    
                      __    __    __    __
                     /  \  /  \  /  \  /  \
                    /    \/    \/    \/    \
    ███████████████/  /██/  /██/  /██/  /████████████████████████
                  /  / \   / \   / \   / \  \____
                 /  /   \_/   \_/   \_/   \    o \__,
                / _/                       \_____/  `
                |/
            ███╗   ███╗ █████╗ ███╗   ███╗██████╗  █████╗
            ████╗ ████║██╔══██╗████╗ ████║██╔══██╗██╔══██╗
            ██╔████╔██║███████║██╔████╔██║██████╔╝███████║
            ██║╚██╔╝██║██╔══██║██║╚██╔╝██║██╔══██╗██╔══██║
            ██║ ╚═╝ ██║██║  ██║██║ ╚═╝ ██║██████╔╝██║  ██║
            ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝ ╚═╝  ╚═╝
    
            mamba (0.15.2) supported by @QuantStack
    
            GitHub:  https://github.com/mamba-org/mamba
            Twitter: https://twitter.com/QuantStack
    
    █████████████████████████████████████████████████████████████
    
    # packages in environment at /home/mark/mambaforge/envs/mcam_dev:
    #
    # Name                    Version                   Build  Channel
    pytest                    6.2.4            py39hf3d152e_0    conda-forge
    pytest-env                0.6.2                      py_0    conda-forge
    pytest-forked             1.3.0              pyhd3deb0d_0    conda-forge
    pytest-localftpserver     1.1.2              pyhd8ed1ab_0    conda-forge
    pytest-qt                 4.0.2              pyhd8ed1ab_0    conda-forge
    pytest-sugar              0.9.4              pyh9f0ad1d_1    conda-forge
    pytest-timeout            1.4.2              pyh9f0ad1d_0    conda-forge
    pytest-xdist              2.3.0              pyhd8ed1ab_0    conda-forge
    

    Command used to run pytest

    pytest test_me.py

    Test file test_me.py

    from time import sleep
    import pytest
    
    
    @pytest.mark.parametrize('time', range(5))
    def test_sleep(time):
        sleep(time)
    

    Output

    Without pytest-sugar. Notice how I captured the name of test_sleep[2] before the result of the test appeared. image

    With pytest-sugar. Notice how I was able to capture the screenshot while test_sleep[4] was running, but before the name of the test appeared image

    enhancement 
    opened by hmaarrfk 1
  • pytest-sugar surpasses hypothesis statistics

    pytest-sugar surpasses hypothesis statistics

    I am running tests with hypothesis and want to see the statistics hypothesis provides. It seems that pytest-sugar doesn't show the statistics.

    Command used to run pytest

    pytest --hypothesis-show-statistics

    Output

    Test session starts (platform: darwin, Python 3.8.2, pytest 6.2.2, pytest-sugar 0.9.4)
    rootdir: /Users/amolgawai/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/algo-practice, configfile: pyproject.toml, testpaths: tests
    plugins: hypothesis-6.1.1, pythonpath-0.7.3, cov-2.11.1, sugar-0.9.4
    collecting ... 
     tests/test_graph_bfs.py ✓✓                                                                                     40% ████       tests/test_sorting.py ✓✓✓                                                                                     100% ██████████
    =================================================== Hypothesis Statistics ====================================================
    Results (0.51s):
           5 passed
    
    

    If I use -p no:sugar, the statistics are shown properly.

    Can pytest-sugar show proper output for hypothesis statistics?

    3rd-party 
    opened by amolgawai 1
  • Feature Request: Integration with Pytest-Parallel as well

    Feature Request: Integration with Pytest-Parallel as well

    I am looking into use pytest-sugar and the fact that it supports pytest-xdist is great, but I was wondering if you were planning on supporting pytest-parallel as well. It has some advantages over pytest-xdist especially for multithreaded tests / concurrency tests.

    It mostly works at the moment out of the box, the only thing is that the progress bar does not currently work. https://pypi.org/project/pytest-parallel/

    enhancement 3rd-party 
    opened by Skylion007 0
  • Status line length miscalculation

    Status line length miscalculation

    When multiple tests are in a single test file, the test result progress bar gets printed for each test in the file, when using pytest-sugar in a windows powershell terminal. Example output:

    Command:

    pytest .\tests\test_1.py
    

    Output:

    Test session starts (platform: win32, Python 3.8.5, pytest 6.1.1, pytest-sugar 0.9.4)  
    rootdir: ..., configfile: pytest.ini
    plugins: forked-1.3.0, mock-3.3.1, pspec-0.0.4, sugar-0.9.4, xdist-2.1.0
    collecting ... 
     test_1.py ✓                                                         25% ██▌       
     test_1.py ✓✓                                                        50% █████     
     test_1.py ✓✓✓                                                       75% ███████▌  
     test_1.py ✓✓✓✓                                                     100% ██████████
    
    Results (0.30s):
           4 passed
    

    The progressbar is rendered so, that it ends right on the right window margin (last character is used by the progressbar)

    I could get it fixed locally by either setting LEN_RIGHT_MARGIN to 1 or inside SugarTerminalReporter.insert_progress by adding 1 less space (num_spaces -1), but I don't know, if these are the correct fixes for the issue.

    I believe some part of the calculation of number of needed spaces to insert into the status line is broken, because for in test runs with errors the lines with "-" or "=" padding are always 1 character shorter than the line with the status line

    dont-know 
    opened by zajosk 0
  • Integration with pytest-subtests

    Integration with pytest-subtests

    When using pytest-subtests and pytest-sugar, the actual subtest name is not reported in the results.

    example:

    import unittest
    
    
    class T(unittest.TestCase):
        def test_foo(self):
            for i in range(5):
                with self.subTest("custom message", i=i):
                    self.assertEqual(i % 2, 0)
    
    
    if __name__ == "__main__":
        unittest.main()
    

    output

    Test session starts (platform: linux, Python 3.8.3, pytest 5.4.3, pytest-sugar 0.9.4)
    rootdir: /home/cdk/dev/expecthon
    plugins: django-3.9.0, sugar-0.9.4, cov-2.10.0, black-0.3.10, subtests-0.3.2
     bla.py ⨯✓                                                                              100% ██████████
    ======================================= short test summary info =======================================
    FAILED bla.py::T::test_foo - AssertionError: 1 != 0
    FAILED bla.py::T::test_foo - AssertionError: 1 != 0
    
    Results (0.13s):
           1 passed
           2 failed
             - bla.py:5 T.test_foo
             - bla.py:5 T.test_foo
    
    

    Expected output

    Test session starts (platform: linux, Python 3.8.3, pytest 5.4.3, pytest-sugar 0.9.4)
    rootdir: /home/cdk/dev/expecthon
    plugins: django-3.9.0, sugar-0.9.4, cov-2.10.0, black-0.3.10, subtests-0.3.2
     bla.py ⨯✓                                                                              100% ██████████
    ======================================= short test summary info =======================================
    FAILED bla.py::T::test_foo (custom message, i=1) - AssertionError: 1 != 0
    FAILED bla.py::T::test_foo (custom message, i=3) - AssertionError: 1 != 0
    
    Results (0.13s):
           1 passed
           2 failed
             - bla.py:5 T.test_foo
               - (custom message, i=1)
               - (custom message, i=3)
    
    3rd-party 
    opened by C0DK 4
Owner
Teemu
Python ❤️ Ruby ❤️ Javascript 💔
Teemu
a wrapper around pytest for executing tests to look for test flakiness and runtime regression

bubblewrap a wrapper around pytest for assessing flakiness and runtime regressions a cs implementations practice project How to Run: First, install de

Anna Nagy 1 Aug 5, 2021
Show surprise when tests are passing

pytest-pikachu pytest-pikachu prints ascii art of Surprised Pikachu when all tests pass. Installation $ pip install pytest-pikachu Usage Pass the --p

Charlie Hornsby 13 Apr 15, 2022
:game_die: Pytest plugin to randomly order tests and control random.seed

pytest-randomly Pytest plugin to randomly order tests and control random.seed. Features All of these features are on by default but can be disabled wi

pytest-dev 471 Dec 30, 2022
A pytest plugin to run an ansible collection's unit tests with pytest.

pytest-ansible-units An experimental pytest plugin to run an ansible collection's unit tests with pytest. Description pytest-ansible-units is a pytest

Community managed Ansible repositories 9 Dec 9, 2022
Given some test cases, this program automatically queries the oracle and tests your Cshanty compiler!

The Diviner A complement to The Oracle for compilers class. Given some test cases, this program automatically queries the oracle and tests your compil

Grant Holmes 2 Jan 29, 2022
Selects tests affected by changed files. Continous test runner when used with pytest-watch.

This is a pytest plug-in which automatically selects and re-executes only tests affected by recent changes. How is this possible in dynamic language l

Tibor Arpas 614 Dec 30, 2022
Useful additions to Django's default TestCase

django-test-plus Useful additions to Django's default TestCase from REVSYS Rationale Let's face it, writing tests isn't always fun. Part of the reason

REVSYS 546 Dec 22, 2022
Useful additions to Django's default TestCase

django-test-plus Useful additions to Django's default TestCase from REVSYS Rationale Let's face it, writing tests isn't always fun. Part of the reason

REVSYS 546 Dec 22, 2022
To automate the generation and validation tests of COSE/CBOR Codes and it's base45/2D Code representations

To automate the generation and validation tests of COSE/CBOR Codes and it's base45/2D Code representations, a lot of data has to be collected to ensure the variance of the tests. This respository was established to collect a lot of different test data and related test cases of different member states in a standardized manner. Each member state can generate a folder in this section.

null 160 Jul 25, 2022
This is a simple software for fetching new changes to remote repositories automatically.

Git Autofetch Git Autofetch is a simple software for fetching new changes from a repo to local repositories after a set time interval. This program is

Shreyas Ashtamkar 10 Jul 21, 2022
Rerun pytest when your code changes

A simple watcher for pytest Overview pytest-watcher is a tool to automatically rerun pytest when your code changes. It looks for the following events:

Olzhas Arystanov 74 Dec 29, 2022
pytest plugin for manipulating test data directories and files

pytest-datadir pytest plugin for manipulating test data directories and files. Usage pytest-datadir will look up for a directory with the name of your

Gabriel Reis 191 Dec 21, 2022
pytest plugin that let you automate actions and assertions with test metrics reporting executing plain YAML files

pytest-play pytest-play is a codeless, generic, pluggable and extensible automation tool, not necessarily test automation only, based on the fantastic

pytest-dev 67 Dec 1, 2022
pytest splinter and selenium integration for anyone interested in browser interaction in tests

Splinter plugin for the pytest runner Install pytest-splinter pip install pytest-splinter Features The plugin provides a set of fixtures to use splin

pytest-dev 238 Nov 14, 2022
Run ISP speed tests and save results

SpeedMon Automatically run periodic internet speed tests and save results to a variety of storage backends. Supported Backends InfluxDB v1 InfluxDB v2

Matthew Carey 9 May 8, 2022
A library to make concurrent selenium tests that automatically download and setup webdrivers

AutoParaSelenium A library to make parallel selenium tests that automatically download and setup webdrivers Usage Installation pip install autoparasel

Ronak Badhe 8 Mar 13, 2022
pytest plugin for a better developer experience when working with the PyTorch test suite

pytest-pytorch What is it? pytest-pytorch is a lightweight pytest-plugin that enhances the developer experience when working with the PyTorch test sui

Quansight 39 Nov 18, 2022
A pytest plugin, that enables you to test your code that relies on a running PostgreSQL Database

This is a pytest plugin, that enables you to test your code that relies on a running PostgreSQL Database. It allows you to specify fixtures for PostgreSQL process and client.

Clearcode 252 Dec 21, 2022