Giter Site home page Giter Site logo

teemu / pytest-sugar Goto Github PK

View Code? Open in Web Editor NEW
1.3K 19.0 73.0 325 KB

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

License: Other

Python 99.63% Shell 0.19% Dockerfile 0.18%
pytest pytest-sugar python testing pytest-plugin

pytest-sugar's Introduction

pytest-sugar โœจ

Build Status PyPI Version Downloads License

This plugin extends pytest by showing failures and errors instantly, adding a progress bar, improving the test results, and making the output look better.

render1667890332624-min

Installation

To install pytest-sugar:

python -m pip install pytest-sugar

Once installed, the plugin is activated automatically. Run your tests normally:

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

How to contribute ๐Ÿ‘ทโ€โ™‚๏ธ

Open in GitHub Codespaces

Make sure to read our Code of Conduct. You can get started modifying the codebase with the following commands. Alternatively, you can try Github Codespaces (click the badge above). Push the changes to your repository & create a pull request.

git clone [email protected]:Teemu/pytest-sugar.git
cd pytest-sugar
python -m venv .venv
source .venv/bin/activate
echo ".venv" >> .git/info/exclude
pip install -e ".[dev]"
pre-commit install

There are two ways of running tests. We have our proper tests:

pytest .

There are also fake tests that can be used to visualise the output:

pytest faketests

When submitting a pull request, please add a RELEASE.md file in the root of the project that contains the release type (major, minor, patch) and a summary of the changes that will be used as the release changelog entry. For example:

Release type: patch

For long-running tests, display minutes and not only seconds.

Requirements

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

  • Python 3.8 or newer
  • pytest 6.2 or newer

Running on Windows

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

Similar projects

pytest-sugar's People

Contributors

albertodonato avatar auvipy avatar avallbona avatar blueyed avatar botpub avatar edwardbetts avatar emlove avatar graingert avatar guillaumefavelier avatar hugovk avatar immerrr avatar jpvanhal avatar justinmayer avatar kman0 avatar last-partizan avatar m3talstorm avatar michael-k avatar moutix avatar msabramo avatar natim avatar ndevenish avatar nicoddemus avatar omerzimp avatar or avatar penguinpee avatar sallner avatar sobolevn avatar suutari-ai avatar teemu avatar thedrow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pytest-sugar's Issues

Doesn't work with pytest-xdist

I'm getting:

[gw54] linux2 Python 2.7.10 cwd: /home/omer/Documents/Projects/zBackend/devices/malware/tests/functional
gw53 C / gw54 CINTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/omer/Documents/Projects/zBackend/.tox/py27-malware-functional/lib/python2.7/site-packages/_pytest/main.py", line 80, in wrap_session
INTERNALERROR>     config.do_configure()
INTERNALERROR>   File "/home/omer/Documents/Projects/zBackend/.tox/py27-malware-functional/lib/python2.7/site-packages/_pytest/config.py", line 618, in do_configure
INTERNALERROR>     self.hook.pytest_configure(config=self)
INTERNALERROR>   File "/home/omer/Documents/Projects/zBackend/.tox/py27-malware-functional/lib/python2.7/site-packages/_pytest/core.py", line 521, in __call__
INTERNALERROR>     return self._docall(self.methods, kwargs)
INTERNALERROR>   File "/home/omer/Documents/Projects/zBackend/.tox/py27-malware-functional/lib/python2.7/site-packages/_pytest/core.py", line 528, in _docall
INTERNALERROR>     firstresult=self.firstresult).execute()
INTERNALERROR>   File "/home/omer/Documents/Projects/zBackend/.tox/py27-malware-functional/lib/python2.7/site-packages/_pytest/core.py", line 394, in execute
INTERNALERROR>     res = method(*args)
INTERNALERROR>   File "/home/omer/Documents/Projects/zBackend/.tox/py27-malware-functional/lib/python2.7/site-packages/pytest_sugar.py", line 122, in pytest_configure
INTERNALERROR>     sugar_reporter = SugarTerminalReporter(standard_reporter)
INTERNALERROR>   File "/home/omer/Documents/Projects/zBackend/.tox/py27-malware-functional/lib/python2.7/site-packages/pytest_sugar.py", line 148, in __init__
INTERNALERROR>     TerminalReporter.__init__(self, reporter.config)
INTERNALERROR> AttributeError: 'NoneType' object has no attribute 'config'
[gw53] node down: Not properly terminated

I'd rather have a responsive CI than a pretty looking log output but if possible I'd like to have both.
Any idea what's broken here?

Traceback for --new-summary

Call: py.test --new-summary --lf

Result:

Traceback (most recent call last):
  File "bin/py.test", line 350, in <module>
    sys.exit(pytest.main())
  File "/.../pytest-2.9.0-py2.7.egg/_pytest/config.py", line 49, in main
    return config.hook.pytest_cmdline_main(config=config)
  File "/.../pytest-2.9.0-py2.7.egg/_pytest/vendored_packages/pluggy.py", line 724, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/.../pytest-2.9.0-py2.7.egg/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/.../pytest-2.9.0-py2.7.egg/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/.../pytest-2.9.0-py2.7.egg/_pytest/vendored_packages/pluggy.py", line 596, in execute
    res = hook_impl.function(*args)
  File "/.../pytest-2.9.0-py2.7.egg/_pytest/main.py", line 119, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/.../pytest-2.9.0-py2.7.egg/_pytest/main.py", line 114, in wrap_session
    exitstatus=session.exitstatus)
  File "/.../pytest-2.9.0-py2.7.egg/_pytest/vendored_packages/pluggy.py", line 724, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/.../pytest-2.9.0-py2.7.egg/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/.../pytest-2.9.0-py2.7.egg/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/.../pytest-2.9.0-py2.7.egg/_pytest/vendored_packages/pluggy.py", line 595, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File "/.../pytest-2.9.0-py2.7.egg/_pytest/vendored_packages/pluggy.py", line 249, in _wrapped_call
    wrap_controller.send(call_outcome)
  File "/.../pytest-2.9.0-py2.7.egg/_pytest/terminal.py", line 378, in pytest_sessionfinish
    self.summary_stats()
  File "/.../pytest_sugar-0.7.1-py2.7.egg/pytest_sugar.py", line 419, in summary_stats
    path, name = report.location[0].rsplit('/', 1)
ValueError: need more than 1 value to unpack

report.location[0] was 'test_suite' in this case.

report.location was: ('test_suite', None, '/src/my.package/src/my/package/composer/tests/../documentedit.txt').

So report.location[2] could be used for the split in this case. Accessing report.location[1] a few lines later should be adapted to be able to handle the None value.

No output while setup is running

If a test has a long setup fixture, it takes a long time before the first test is executed. Without pytest-sugar, pytest already outputs the test name itself, so you get immediate feedback of what test is trying to execute. With pytest-sugar you get no output, so it appears to be stuck (but it's instead waiting for the setup to complete).

Command used to run py.test

py.test test_example.py

Test file

import time
import pytest

@pytest.fixture
def long_setup():
    time.sleep(10)

def test(long_setup):
    pass

Output

The output is correct, but for 10 seconds the screen looks like this:

Test session starts (platform: linux, Python 3.6.4, pytest 3.3.2, pytest-sugar 0.9.0)
rootdir: /home/micheleb/local/test/pytest, inifile:
plugins: sugar-0.9.0

Expected instead:

Test session starts (platform: linux, Python 3.6.4, pytest 3.3.2, pytest-sugar 0.9.0)
rootdir: /home/micheleb/local/test/pytest, inifile:
plugins: sugar-0.9.0

 test_example.py

UnicodeDecodeError if the crashline contains non-ASCII characters

I have tests that failed with assert 'OCZEKUJฤ„CY' == 'Nieaktywny' as their crash line. This breaks pytest-sugar:

Results (24.11s):
   9 passed
   3 failed
Traceback (most recent call last):
  File "/home/tkontusz/.virtualenvs/book/bin/py.test", line 9, in <module>
    load_entry_point('pytest==2.5.2', 'console_scripts', 'py.test')()
  File "/home/tkontusz/.virtualenvs/book/local/lib/python2.7/site-packages/_pytest/config.py", line 20, in main
    return config.hook.pytest_cmdline_main(config=config)
  File "/home/tkontusz/.virtualenvs/book/local/lib/python2.7/site-packages/_pytest/core.py", line 377, in __call__
    return self._docall(methods, kwargs)
  File "/home/tkontusz/.virtualenvs/book/local/lib/python2.7/site-packages/_pytest/core.py", line 388, in _docall
    res = mc.execute()
  File "/home/tkontusz/.virtualenvs/book/local/lib/python2.7/site-packages/_pytest/core.py", line 289, in execute
    res = method(**kwargs)
  File "/home/tkontusz/.virtualenvs/book/local/lib/python2.7/site-packages/_pytest/main.py", line 112, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/home/tkontusz/.virtualenvs/book/local/lib/python2.7/site-packages/_pytest/main.py", line 105, in wrap_session
    exitstatus=session.exitstatus)
  File "/home/tkontusz/.virtualenvs/book/local/lib/python2.7/site-packages/_pytest/core.py", line 377, in __call__
    return self._docall(methods, kwargs)
  File "/home/tkontusz/.virtualenvs/book/local/lib/python2.7/site-packages/_pytest/core.py", line 388, in _docall
    res = mc.execute()
  File "/home/tkontusz/.virtualenvs/book/local/lib/python2.7/site-packages/_pytest/core.py", line 289, in execute
    res = method(**kwargs)
  File "/home/tkontusz/.virtualenvs/book/local/lib/python2.7/site-packages/_pytest/terminal.py", line 343, in pytest_sessionfinish
    self.summary_stats()
  File "/home/tkontusz/.virtualenvs/book/local/lib/python2.7/site-packages/pytest_sugar.py", line 310, in summary_stats
    self._getcrashline(report) #.decode(locale.getpreferredencoding())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 82: ordinal not in range(128)

I tried just using .decode(locale.getpreferredencoding(), 'ignore') on the result of _getcrashline and it works, if that sounds like a good solution I can make a PR.

pytest-sugar 0.3.0 on PyPI missing README.rst

[email protected] โฎ€ ~ โฎ€ clean โฎ€
 โฏ pip install pytest_sugar
Downloading/unpacking pytest-sugar
  Using download cache from /Users/marca/.pip/download-cache/http%3A%2F%2Flocalhost%3A3141%2Froot%2Fpypi%2F%2Bf%2Fe1fe15005822e871d29a23effb159251%2Fpytest-sugar-0.3.0.tar.gz
  Running setup.py egg_info for package pytest-sugar
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/Users/marca/python/virtualenvs/clean/build/pytest-sugar/setup.py", line 11, in <module>
        long_description=open("README.rst").read(),
    IOError: [Errno 2] No such file or directory: 'README.rst'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/Users/marca/python/virtualenvs/clean/build/pytest-sugar/setup.py", line 11, in <module>

    long_description=open("README.rst").read(),

IOError: [Errno 2] No such file or directory: 'README.rst'

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /Users/marca/python/virtualenvs/clean/build/pytest-sugar
Storing complete log in /Users/marca/.pip/pip.log
[email protected] โฎ€ ~ โฎ€ clean โฎ€
 โฏ wget https://pypi.python.org/packages/source/p/pytest-sugar/pytest-sugar-0.3.0.tar.gz\#md5\=e1fe15005822e871d29a23effb159251
--2014-02-05 14:56:34--  https://pypi.python.org/packages/source/p/pytest-sugar/pytest-sugar-0.3.0.tar.gz
Resolving pypi.python.org... 199.27.77.184, 199.27.79.184
Connecting to pypi.python.org|199.27.77.184|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4738 (4.6K) [application/octet-stream]
Saving to: โ€˜pytest-sugar-0.3.0.tar.gzโ€™

100%[==================================================================================================================================================================================================================================================================================>] 4,738       --.-K/s   in 0s

2014-02-05 14:56:34 (103 MB/s) - โ€˜pytest-sugar-0.3.0.tar.gzโ€™ saved [4738/4738]


 [email protected] โฎ€ ~ โฎ€ clean โฎ€
 โฏ tar tvzf pytest-sugar-0.3.0.tar.gz
drwxr-xr-x  0 bansku bansku      0 Feb  5 06:18 pytest-sugar-0.3.0/
-rw-r--r--  0 bansku bansku     59 Feb  5 06:18 pytest-sugar-0.3.0/setup.cfg
-rw-r--r--  0 bansku bansku   2364 Feb  5 06:18 pytest-sugar-0.3.0/PKG-INFO
-rw-r--r--  0 bansku bansku   1537 Feb  5 06:04 pytest-sugar-0.3.0/setup.py
-rw-r--r--  0 bansku bansku  11622 Feb  5 06:05 pytest-sugar-0.3.0/pytest_sugar.py
drwxr-xr-x  0 bansku bansku      0 Feb  5 06:18 pytest-sugar-0.3.0/pytest_sugar.egg-info/
-rw-r--r--  0 bansku bansku     13 Feb  5 06:18 pytest-sugar-0.3.0/pytest_sugar.egg-info/top_level.txt
-rw-r--r--  0 bansku bansku    277 Feb  5 06:18 pytest-sugar-0.3.0/pytest_sugar.egg-info/SOURCES.txt
-rw-r--r--  0 bansku bansku     11 Feb  5 06:18 pytest-sugar-0.3.0/pytest_sugar.egg-info/requires.txt
-rw-r--r--  0 bansku bansku   2364 Feb  5 06:18 pytest-sugar-0.3.0/pytest_sugar.egg-info/PKG-INFO
-rw-r--r--  0 bansku bansku      1 Feb  5 06:10 pytest-sugar-0.3.0/pytest_sugar.egg-info/not-zip-safe
-rw-r--r--  0 bansku bansku      1 Feb  5 06:18 pytest-sugar-0.3.0/pytest_sugar.egg-info/dependency_links.txt
-rw-r--r--  0 bansku bansku     33 Feb  5 06:18 pytest-sugar-0.3.0/pytest_sugar.egg-info/entry_points.txt

No README.rst

--nosugar does not completely disable sugar

When running the tests in Jenkins with the --nosugar option it displays the escape sequences to render the test passes or failures in color. This is not the case if pytest-sugar ist not installed.

Gibberish stdout in win 8 32 bit py34

Terminal color codes are not properly reflected when using pysugar in windows.

Sample output:

Test session starts (platform: win32, Python 3.4.0, pytest 2.6.4, pytest-sugar 0.3.4)
plugins: sugar, instafail

test_sugar.py \r \x1b[1;30m\x1b[0mtest_sugar.py \x1b[92m\u2713\x1b[0m 7% \x1b[92m\x1b[100m\u
test_sugar.py \r \x1b[1;30m\x1b[0mtest_sugar.py \x1b[92m\u2713\x1b[0m\x1b[92m\u2713\x1b[0m 13%
test_sugar.py \r \x1b[1;30m\x1b[0mtest_sugar.py \x1b[92m\u2713\x1b[0m\x1b[92m\u2713\x1b[0m\x1b[92m\u2713\x1b[0m
test_sugar.py \r \x1b[1;30m\x1b[0mtest_sugar.py \x1b[92m\u2713\x1b[0m\x1b[92m\u2713\x1b[0m\x1b[92m\u2713\x1b[0m\x1b[92m\u2713\x1b[0m
27% \x1b[92m\u2713\x1b[0m\x1b[92m\u2713\x1b[0m\x1b[92m\u2713\x1b[0m\x1b[92m\u2713\x1b[0m\x1
b[92m\u2713\x1b[0m\x1b[92m\u2713\x1b[0m\x1b[92m\u2713\x1b[0m\x1b[92m\u2713\x1b[0m\x1b[92m\u2713\x1b[0m\x1b[92m\u2713\x1b[0m\x1b[92m\u2713\x1
b[0m\x1b[92m\u2713\x1b[0m\x1b[92m\u2713\x1b[0m\x1b[92m\u2713\x1b[0m\x1b[92m\u2713\x1b[0m 100% \x1b[92m\x1b[100m\u
2589\u2589\u2589\u2589\u2589\u2589\u2589\u2589\u2589\u2589\u2589\x1b[0m\x1b[1;30m\x1b[100m\x1b[0m

Timestamps in output

For a long build, it is useful to have timestamps.
It would be great to have a timestamp in the front with a cli arg.

Example:

[hh:mm:ss DD:MM:YYYY] tests/add_text_tests.pyTestStarList.test_basic โœ“                                      0%           
[hh:mm:ss DD:MM:YYYY] tests/add_text_tests.pyTestStarList.test_with_params โœ“                                0%            

install won't work? ("distribute" ?)

This is Windows 7 so I'm not sure I can use this plugin anyway, but it wouldn't install despite having Python 2.7.12 and pytest-3.2.1 installed.

C:\>pip install pytest-sugar
Downloading/unpacking pytest-sugar
  Downloading pytest-sugar-0.9.0.tar.gz
  Running setup.py egg_info for package pytest-sugar

Requirement already satisfied (use --upgrade to upgrade): pytest>=2.9 in c:\app\python\anaconda\1.6.0\lib\site-packages (from pytest
-sugar)
Downloading/unpacking termcolor>=1.1.0 (from pytest-sugar)
  Downloading termcolor-1.1.0.tar.gz
  Running setup.py egg_info for package termcolor

Requirement already satisfied (use --upgrade to upgrade): py>=1.4.33 in c:\app\python\anaconda\1.6.0\lib\site-packages (from pytest>
=2.9->pytest-sugar)
Downloading/unpacking distribute==0.0 (from pytest>=2.9->pytest-sugar)
  Could not find a version that satisfies the requirement distribute==0.0 (from pytest>=2.9->pytest-sugar) (from versions: 0.6.26, 0
.6.46, 0.6.10, 0.6.15, 0.6.13, 0.6.14, 0.6.7, 0.6.29, 0.6.16, 0.6.5, 0.6.25, 0.6, 0.6.26, 0.6.41, 0.6.28, 0.6.33, 0.6.27, 0.6.18, 0.
6.45, 0.6.10, 0.6.1, 0.6.12, 0.6.38, 0.6.32, 0.6.40, 0.6.1, 0.6.36, 0.6.35, 0.6.38, 0.6.47, 0.7.3, 0.6.17, 0.6.25, 0.6.11, 0.6.21, 0
.6.49, 0.6.43, 0.6.31, 0.6.21, 0.6.15, 0.6.17, 0.6.48, 0.6.33, 0.6.3, 0.6.19, 0.6.2, 0.6.24, 0.6.43, 0.6.27, 0.6.32, 0.6.48, 0.6.44,
 0.6.14, 0.6.39, 0.6.41, 0.6.44, 0.6.34, 0.6.29, 0.6.37, 0.6.9, 0.6.11, 0.6.3, 0.6.45, 0.6.24, 0.6.5, 0.6.18, 0.6.47, 0.6.36, 0.6.40
, 0.6.4, 0.6.13, 0.6.2, 0.6.42, 0.6.7, 0.6.28, 0.6.12, 0.6.30, 0.6.4, 0.6.6, 0.6.16, 0.6.35, 0.6.46, 0.6.19, 0.6.30, 0.6.31, 0.6.9,
0.6.6, 0.6.8, 0.6.49, 0.6.37, 0.6.8, 0.6, 0.6.42, 0.6.34, 0.6.39, 0.6.20, 0.6.20)
Cleaning up...
No distributions matching the version for distribute==0.0 (from pytest>=2.9->pytest-sugar)
Storing complete log in C:\Users\C15205\pip\pip.log

C:\>py.test --version
This is pytest version 3.2.1, imported from c:\app\python\anaconda\1.6.0\lib\site-packages\pytest.pyc

C:\>py.test tests/test_1.py
============================= test session starts =============================
platform win32 -- Python 2.7.12, pytest-3.2.1, py-1.4.34, pluggy-0.4.0
rootdir: C:\, inifile:

No separator between file and test name in verbose mode

When using --verbose with pytest-sugar installed the test name is squashed up right next to the test file name.

Example:

 tests/test_utils_config.pytest_getitem_access_proxy_getattr โœ“                   2% โ–Ž
 tests/test_utils_config.pytest_getitem_access_proxy_getattr_nested โœ“            4% โ–
 tests/test_utils_config.pytest_getitem_access_proxy_getattr_real โœ“              6% โ–‹
 tests/test_utils_config.pytest_getitem_access_proxy_getitem โœ“                   8% โ–Š
 tests/test_utils_config.pytest_getitem_access_proxy_str โœ“                      10% โ–‰
 tests/test_utils_config.pytest_getitem_access_proxy_repr โœ“                     12% โ–ˆโ–Ž
 tests/test_utils_config.pytest_getitem_access_proxy_setattr โœ“                  13% โ–ˆโ–
 tests/test_utils_config.pytest_getitem_access_proxy_setattr_nested โœ“           15% โ–ˆโ–‹
 tests/test_utils_config.pytest_getitem_access_proxy_setitem โœ“                  17% โ–ˆโ–Š

Plain pytest uses :: to separate the two.

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

Result summary counts exception in fixture as failure

Running the tests without pytest-sugar counts an exception in the fixture as error while running with pytest-sugar the same exception is counted as a failure.

Example without py-test:

$ bin/py.test -k test___getattr___looks_up_key_in_metadata -p no:sugar
=========================== test session starts ===========================
platform darwin -- Python 2.7.11, pytest-2.9.0, py-1.4.30, pluggy-0.3.1
rootdir: /Users/..., inifile: pytest.ini
plugins: gocept.pytestlayer-2.1, cov-1.8.1, rerunfailures-0.5, remove-stale-bytecode-1.0
collected 494 items

xxx/test_article.py EE

[โ€ฆ]
================= 493 deselected, 2 error in 8.55 seconds =======================

Same example with pytest-sugar:

$ bin/py.test -k test___getattr___looks_up_key_in_metadata
Test session starts (platform: darwin, Python 2.7.11, pytest 2.9.0, pytest-sugar 0.7.1)
rootdir: /Users/..., inifile: pytest.ini
plugins: gocept.pytestlayer-2.1, cov-1.8.1, rerunfailures-0.5, remove-stale-bytecode-1.0, sugar-0.7.1

[โ€ฆ]
======== 493 tests deselected by '-ktest___getattr___looks_up_key_in_metadata' =========

Results (6.26s):
         2 failed
         - /Users/.../testing.py:74: RuntimeError: ...
         - /Users/.../Connection.py:248: AttributeError: ...
     493 deselected

Expectation: Exceptions during the setup of the test should be counted as errors as py.test does it.
What is the reason not to do so in pytest-sugar?

(reopen) UnboundLocalError when used together with pytest-rerunfailures

Issue #80 seems to have re-emerged. Command used to run pytest is just pytest with flags from pytest-rerunfailures: in this case I believe it was pytest --reruns=3.


Just got this with pytest-sugar 0.9.1. Here are all my pytest-related dependencies:

$ pip freeze | grep pytest
pytest==3.5.1
pytest-cov==2.5.1
pytest-django==3.2.1
pytest-env==0.6.2
pytest-forked==0.2
pytest-rerunfailures==4.1
pytest-sugar==0.9.1
pytest-xdist==1.22.2
INTERNALERROR>     def pytest_runtest_logreport(self, report):
INTERNALERROR>         global LEN_PROGRESS_BAR_SETTING, LEN_PROGRESS_BAR
INTERNALERROR>
INTERNALERROR>         res = pytest_report_teststatus(report=report)
INTERNALERROR>         cat, letter, word = res
INTERNALERROR>         self.stats.setdefault(cat, []).append(report)
INTERNALERROR>
INTERNALERROR>         if not LEN_PROGRESS_BAR:
INTERNALERROR>             if LEN_PROGRESS_BAR_SETTING.endswith('%'):
INTERNALERROR>                 LEN_PROGRESS_BAR = (
INTERNALERROR>                     self._tw.fullwidth *
INTERNALERROR>                     int(LEN_PROGRESS_BAR_SETTING[:-1]) // 100
INTERNALERROR>                 )
INTERNALERROR>             else:
INTERNALERROR>                 LEN_PROGRESS_BAR = int(LEN_PROGRESS_BAR_SETTING)
INTERNALERROR>
INTERNALERROR>         self.reports.append(report)
INTERNALERROR>         if report.outcome == 'failed':
INTERNALERROR>             print("")
INTERNALERROR>             self.print_failure(report)
INTERNALERROR>             # Ignore other reports or it will cause duplicated letters
INTERNALERROR>         if report.when == 'teardown':
INTERNALERROR>             self.tests_taken += 1
INTERNALERROR>             self.insert_progress(report)
INTERNALERROR>             path = os.path.join(os.getcwd(), report.location[0])
INTERNALERROR>
INTERNALERROR>         if report.when == 'call' or report.skipped:
INTERNALERROR>             path = self.report_key(report)
INTERNALERROR>             if path not in self.current_line_nums:
INTERNALERROR>                 self.begin_new_line(report, print_filename=True)
INTERNALERROR>             elif self.reached_last_column_for_test_status(report):
INTERNALERROR>                 # Print filename if another line was inserted in-between
INTERNALERROR>                 print_filename = (
INTERNALERROR>                     self.current_line_nums[self.report_key(report)] !=
INTERNALERROR>                     self.current_line_num)
INTERNALERROR>                 self.begin_new_line(report, print_filename)
INTERNALERROR>
INTERNALERROR>             self.current_lines[path] = self.current_lines[path] + letter
INTERNALERROR>
INTERNALERROR>             block = int(
INTERNALERROR>                 float(self.tests_taken) * LEN_PROGRESS_BAR / self.tests_count
INTERNALERROR>                 if self.tests_count else 0
INTERNALERROR>             )
INTERNALERROR>             if report.failed:
INTERNALERROR>                 if (
INTERNALERROR>                     not self.progress_blocks or
INTERNALERROR>                     self.progress_blocks[-1][0] != block
INTERNALERROR>                 ):
INTERNALERROR>                     self.progress_blocks.append([block, False])
INTERNALERROR>                 elif (
INTERNALERROR>                     self.progress_blocks and
INTERNALERROR>                     self.progress_blocks[-1][0] == block
INTERNALERROR>                 ):
INTERNALERROR>                     self.progress_blocks[-1][1] = False
INTERNALERROR>             else:
INTERNALERROR>                 if (
INTERNALERROR>                     not self.progress_blocks or
INTERNALERROR>                     self.progress_blocks[-1][0] != block
INTERNALERROR>                 ):
INTERNALERROR>                     self.progress_blocks.append([block, True])
INTERNALERROR>
INTERNALERROR>             if not letter and not word:
INTERNALERROR>                 return
INTERNALERROR>             if self.verbosity > 0:
INTERNALERROR>                 if isinstance(word, tuple):
INTERNALERROR>                     word, markup = word
INTERNALERROR>                 else:
INTERNALERROR>                     if report.passed:
INTERNALERROR>                         markup = {'green': True}
INTERNALERROR>                     elif report.failed:
INTERNALERROR>                         markup = {'red': True}
INTERNALERROR>                     elif report.skipped:
INTERNALERROR>                         markup = {'yellow': True}
INTERNALERROR>                 line = self._locationline(str(report.fspath), *report.location)
INTERNALERROR>                 if hasattr(report, 'node'):
INTERNALERROR>                     self._tw.write("\r\n")
INTERNALERROR>                     self.current_line_num += 1
INTERNALERROR>                     if hasattr(report, 'node'):
INTERNALERROR>                         self._tw.write("[%s] " % report.node.gateway.id)
INTERNALERROR> >                   self._tw.write(word, **markup)
INTERNALERROR> E                   UnboundLocalError: local variable 'markup' referenced before assignment
INTERNALERROR>
INTERNALERROR> block      = 1
INTERNALERROR> cat        = 'rerun'
INTERNALERROR> letter     = 'R'
[...]
INTERNALERROR> res        = ('rerun', 'R', 'RERUN')
INTERNALERROR> self       = <pytest_sugar.SugarTerminalReporter object at 0x7fe5856a41d0>
INTERNALERROR> word       = 'RERUN'

Fails with --lf option of pytest-cache

When using the --lf option of pytest-cache to only run tests that failed last time, this exception is raised:

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "./lib/python3.4/site-packages/_pytest/main.py", line 84, in wrap_session
INTERNALERROR>     doit(config, session)
INTERNALERROR>   File "./lib/python3.4/site-packages/_pytest/main.py", line 122, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "./lib/python3.4/site-packages/_pytest/core.py", line 413, in __call__
INTERNALERROR>     return self._docall(methods, kwargs)
INTERNALERROR>   File "./lib/python3.4/site-packages/_pytest/core.py", line 424, in _docall
INTERNALERROR>     res = mc.execute()
INTERNALERROR>   File "./lib/python3.4/site-packages/_pytest/core.py", line 315, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "./lib/python3.4/site-packages/_pytest/main.py", line 142, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "./lib/python3.4/site-packages/_pytest/core.py", line 413, in __call__
INTERNALERROR>     return self._docall(methods, kwargs)
INTERNALERROR>   File "./lib/python3.4/site-packages/_pytest/core.py", line 424, in _docall
INTERNALERROR>     res = mc.execute()
INTERNALERROR>   File "./lib/python3.4/site-packages/_pytest/core.py", line 315, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "./lib/python3.4/site-packages/pytest_timeout.py", line 72, in pytest_runtest_protocol
INTERNALERROR>     return __multicall__.execute()
INTERNALERROR>   File "./lib/python3.4/site-packages/_pytest/core.py", line 315, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "./lib/python3.4/site-packages/_pytest/runner.py", line 65, in pytest_runtest_protocol
INTERNALERROR>     runtestprotocol(item, nextitem=nextitem)
INTERNALERROR>   File "./lib/python3.4/site-packages/_pytest/runner.py", line 77, in runtestprotocol
INTERNALERROR>     nextitem=nextitem))
INTERNALERROR>   File "./lib/python3.4/site-packages/_pytest/runner.py", line 113, in call_and_report
INTERNALERROR>     hook.pytest_runtest_logreport(report=report)
INTERNALERROR>   File "./lib/python3.4/site-packages/_pytest/main.py", line 166, in call_matching_hooks
INTERNALERROR>     return hookmethod.pcall(plugins, **kwargs)
INTERNALERROR>   File "./lib/python3.4/site-packages/_pytest/core.py", line 417, in pcall
INTERNALERROR>     return self._docall(methods, kwargs)
INTERNALERROR>   File "./lib/python3.4/site-packages/_pytest/core.py", line 424, in _docall
INTERNALERROR>     res = mc.execute()
INTERNALERROR>   File "./lib/python3.4/site-packages/_pytest/core.py", line 315, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "./lib/python3.4/site-packages/pytest_sugar.py", line 230, in pytest_runtest_logreport
INTERNALERROR>     self.overwrite(self.insert_progress())
INTERNALERROR>   File "./lib/python3.4/site-packages/pytest_sugar.py", line 180, in insert_progress
INTERNALERROR>     append_string = get_progress_bar()
INTERNALERROR>   File "./lib/python3.4/site-packages/pytest_sugar.py", line 173, in get_progress_bar
INTERNALERROR>     progressbar += PROGRESS_BAR_BLOCKS[14 - rem]
INTERNALERROR> IndexError: list index out of range

xfail test is not reported as such if parametrized

    @pytest.mark.xfail(reason="Not implemented")
    @pytest.mark.parametrize('controller', ['found'])
    def inactivated_objects_should_not_be_found(w)

doesn't appear in the results (neither with an 'x', neither in the summary as xfailed).
But the following test does:

    @pytest.mark.xfail(reason="Not implemented")
    def inactivated_objects_should_not_be_found(w)

UnboundLocalError when used together with pytest-rerunfailures

I am using pytest-sugar together with pytest-rerunfailures (version 1.0.1) and marked a test using @pytest.mark.flaky(reruns=3). When this test ist run again because it failed I get the following internal error:

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File ".../pytest-2.7.3-py2.7.egg/_pytest/main.py", line 84, in wrap_session
INTERNALERROR>     doit(config, session)
INTERNALERROR>   File ".../pytest-2.7.3-py2.7.egg/_pytest/main.py", line 122, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File ".../pytest-2.7.3-py2.7.egg/_pytest/core.py", line 521, in __call__
INTERNALERROR>     return self._docall(self.methods, kwargs)
INTERNALERROR>   File ".../pytest-2.7.3-py2.7.egg/_pytest/core.py", line 528, in _docall
INTERNALERROR>     firstresult=self.firstresult).execute()
INTERNALERROR>   File ".../pytest-2.7.3-py2.7.egg/_pytest/core.py", line 394, in execute
INTERNALERROR>     res = method(*args)
INTERNALERROR>   File ".../pytest-2.7.3-py2.7.egg/_pytest/main.py", line 142, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File ".../pytest-2.7.3-py2.7.egg/_pytest/core.py", line 521, in __call__
INTERNALERROR>     return self._docall(self.methods, kwargs)
INTERNALERROR>   File ".../pytest-2.7.3-py2.7.egg/_pytest/core.py", line 528, in _docall
INTERNALERROR>     firstresult=self.firstresult).execute()
INTERNALERROR>   File ".../pytest-2.7.3-py2.7.egg/_pytest/core.py", line 393, in execute
INTERNALERROR>     return wrapped_call(method(*args), self.execute)
INTERNALERROR>   File ".../pytest-2.7.3-py2.7.egg/_pytest/core.py", line 113, in wrapped_call
INTERNALERROR>     return call_outcome.get_result()
INTERNALERROR>   File ".../pytest-2.7.3-py2.7.egg/_pytest/core.py", line 138, in get_result
INTERNALERROR>     py.builtin._reraise(*ex)
INTERNALERROR>   File ".../pytest-2.7.3-py2.7.egg/_pytest/core.py", line 123, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File ".../pytest-2.7.3-py2.7.egg/_pytest/core.py", line 394, in execute
INTERNALERROR>     res = method(*args)
INTERNALERROR>   File "build/bdist.macosx-10.11-x86_64/egg/pytest_rerunfailures.py", line 86, in pytest_runtest_protocol
INTERNALERROR>     item.ihook.pytest_runtest_logreport(report=report)
INTERNALERROR>   File ".../pytest-2.7.3-py2.7.egg/_pytest/core.py", line 521, in __call__
INTERNALERROR>     return self._docall(self.methods, kwargs)
INTERNALERROR>   File ".../pytest-2.7.3-py2.7.egg/_pytest/core.py", line 528, in _docall
INTERNALERROR>     firstresult=self.firstresult).execute()
INTERNALERROR>   File ".../pytest-2.7.3-py2.7.egg/_pytest/core.py", line 394, in execute
INTERNALERROR>     res = method(*args)
INTERNALERROR>   File ".../pytest_sugar-0.6.0-py2.7.egg/pytest_sugar.py", line 353, in pytest_runtest_logreport
INTERNALERROR>     res = pytest_report_teststatus(report=report)
INTERNALERROR>   File ".../pytest_sugar-0.6.0-py2.7.egg/pytest_sugar.py", line 166, in pytest_report_teststatus
INTERNALERROR>     return report.outcome, letter, report.outcome.upper()
INTERNALERROR> UnboundLocalError: local variable 'letter' referenced before assignment

Be friendlier w/_pytest.pytester

When testing fixtures using _pytest.pytester with pytest-sugar installed, it is necessary to explicitly disable with -p no:sugar in order to match output from a testdir fixture, like the example in the pytest plugin for cookiecutter:

def test_bar_fixture(testdir):
    """Make sure that pytest accepts our fixture."""

    # create a temporary pytest test module
    testdir.makepyfile("""
        def test_sth(bar):
            assert bar == "europython2015"
    """)

    # run pytest with the following cmd args
    result = testdir.runpytest(
        '--foo=europython2015',
        '-v'
    )

    # fnmatch_lines does an assertion internally
    result.stdout.fnmatch_lines([
        '*::test_sth PASSED',
    ])

In order for this to work w/pytest-sugar installed, one must add '-p no:sugar', which seems like an awfully specific piece to have to add; it also means that running tests for someone else's plugins that use pytester will fail with pytest-sugar installed (which can presumably be worked around by passing the argument in an environment variable).

One way to solve this problem is to check the configuration that --color= creates (after "auto" status has been determined) -- effectively making sugar sensitive to running in non-interactive/non-terminal environments in general, which is probably ideal. This might also help with the pytest-xdist issues that I see here in the Github issue tracker, although I haven't looked at them closely enough to know if this is the case.

xpassed shows up green

If there is an xpass (expected failure which unexpectedly passed) it shows up in green color in the results like the passed tests.

Expected behavior: Handle xpass like fail but count it separately.

In constrast xfail looks like a fail but it should look like skip in my opinion.

progress bar doesn't update in place

I just installed pytest-sugar, and the progress bar doesn't get updated in-place for failures. Is this by design? it looks like it works with passing tests. Any ideas?

Also, the progress bar doesn't go to 100% for very very short tests.

(venv)  ~/dev/personal/swarmci ๎‚ฐ ๎‚  prototyping โ—โœš ๎‚ฐ python -m pytest -s --tb=no tests/
Test session starts (platform: darwin, Python 3.5.1, pytest 2.9.2, pytest-sugar 0.7.1)
rootdir: /Users/WesM/dev/personal/swarmci/tests, inifile:
plugins: sugar-0.7.1

 unit/test_job.py โœ“โœ“โœ“                                                                                                      14% โ–ˆโ–
 unit/agents/build/test_init.py โœ“                                                                                          18% โ–ˆโ–Š

 unit/agents/build/test_stage_runner.py โจฏ                                                                                  23% โ–ˆโ–ˆโ–
 unit/agents/build/test_stage_runner.py โจฏโจฏ                                                                                 27% โ–ˆโ–ˆโ–Š
 unit/agents/build/test_stage_runner.py โจฏโจฏโจฏ                                                                                32% โ–ˆโ–ˆโ–ˆโ–Ž
 unit/agents/build/test_stage_runner.py โจฏโจฏโจฏโจฏ                                                                               36% โ–ˆโ–ˆโ–ˆโ–‹
 unit/agents/build/test_stage_runner.py โจฏโจฏโจฏโจฏโจฏ                                                                              41% โ–ˆโ–ˆโ–ˆโ–ˆโ–

 unit/agents/execution/test_job_flow.py โจฏ                                                                                  45% โ–ˆโ–ˆโ–ˆโ–ˆโ–‹
 unit/agents/execution/test_job_flow.py โจฏโจฏ                                                                                 50% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
 unit/agents/execution/test_job_flow.py โจฏโจฏโจฏ                                                                                55% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Œ
 unit/agents/execution/test_job_flow.py โจฏโจฏโจฏโจฏ                                                                               59% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‰
 unit/agents/execution/test_job_flow.py โจฏโจฏโจฏโจฏโจฏ                                                                              64% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–
 unit/agents/execution/test_job_flow.py โจฏโจฏโจฏโจฏโจฏโจฏ                                                                             68% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Š
 unit/agents/execution/test_job_flow.py โจฏโจฏโจฏโจฏโจฏโจฏโจฏ                                                                            73% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–
 unit/agents/execution/test_job_flow.py โจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏ                                                                           77% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Š
 unit/agents/execution/test_job_flow.py โจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏ                                                                          82% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Ž
 unit/agents/execution/test_job_flow.py โจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏ                                                                         86% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‹
 unit/agents/execution/test_job_flow.py โจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏ                                                                        91% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–
 unit/agents/execution/test_job_flow.py โจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏ                                                                       95% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‹
 unit/agents/execution/test_job_flow.py โจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏโจฏ                                                                     100% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ

Results (0.16s):
       4 passed
      18 failed

tests skipped with pytest.mark.skipif not shown at all

If I use pytest.mark.skipif for a test, the test is not shown as
'skipped' with pytest-sugar, while regular pytest does.
If I use nose.plugins.skip.SkipTest from a test instead, pytest-sugar
does see it as skipped.

Example code is the following:

import pytest
import nose

def test_foo():
    assert True

@pytest.mark.skipif(True, reason='testing skipping')
def test_skipped():
    assert False

def test_nose_skipped():
    raise nose.plugins.skip.SkipTest('nose skipping')
    assert False

I tried to add some debug statements in pytest_sugar.py, and noticed
that for the skipif test there is a 'setup' trigger where
report.status says 'skipped' but it becomes 'passed' in the 'teardown'
trigger. There is no 'call' trigger for that skipped test.
I have not been able to determine any useful things further.

This is reported against pytest-sugar 0.5.1 and pytest 2.8.7.
I verified that the same problem is present with older versions of pytest-sugar, so it seems this never worked.

Skipped tests are not shown if skipping is due to fixtures

If a test is skipped due to a fixture causing the skip, the test is not shown at all. Here's a minimal example, test_simple.py:

import pytest


@pytest.fixture
def skipfixture():
    pytest.skip('fixture not available, should skip')


def test_passes():
    pass


def test_with_skipfixture(skipfixture):
    pass


def test_skip_manually():
    pytest.skip('this was skipped inside the test function')

The output from py.test -v test_simple.py without pytest_sugar 4.0 installed:

[...]
test_simple.py::test_passes PASSED
test_simple.py::test_with_skipfixture SKIPPED
test_simple.py::test_skip_manually SKIPPED

============================== 1 passed, 2 skipped in 0.01 seconds ==============================

With sugar, however:

 tests/test_simple.pytest_passes โœ“                                                 67% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‹   
 tests/test_simple.pytest_skip_manually โšซ                                         100% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ

Results (0.01s):
       1 passed
       1 skipped

Note that test_with_skipfixture is missing.

Missing "short test summary info" report for skips

When using pytest-sugar, the "short test summary info" (via py.test -ra) is not displayed:

======โ€ฆ short test summary info โ€ฆ=====
SKIP [1] โ€ฆ/app/plugin.py:20: --foo-bar-baz is not provided.

The test is skipped using pytest.skip() from a fixture.

Also, I've noticed a difference between using --nosugar and -p no:sugar: --nosugar would still display โšซโœ“ instead of just s?!

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 1064: ordinal not in range(128)

Tried to install it on Python 3.4 and I got this:

$ pip install pytest-sugar 
Downloading/unpacking pytest-sugar
  Downloading pytest-sugar-0.3.4.tar.gz
  Running setup.py (path:/private/var/folders/nc/6ynt7q0n02d5znfl939lh23w0000gp/T/pip_build_negval/pytest-sugar/setup.py) egg_info for package pytest-sugar
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/private/var/folders/nc/6ynt7q0n02d5znfl939lh23w0000gp/T/pip_build_negval/pytest-sugar/setup.py", line 28, in <module>
        long_description=open("README.rst").read(),
      File "/usr/local/opt/pyenv/versions/3.4.2/lib/python3.4/encodings/ascii.py", line 26, in decode
        return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 1064: ordinal not in range(128)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/private/var/folders/nc/6ynt7q0n02d5znfl939lh23w0000gp/T/pip_build_negval/pytest-sugar/setup.py", line 28, in <module>

    long_description=open("README.rst").read(),

  File "/usr/local/opt/pyenv/versions/3.4.2/lib/python3.4/encodings/ascii.py", line 26, in decode

    return codecs.ascii_decode(input, self.errors)[0]

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 1064: ordinal not in range(128)

----------------------------------------
Cleaning up...

Also, I found out where strange characters are:

curl https://raw.githubusercontent.com/Frozenball/pytest-sugar/master/README.rst | iconv -t ASCII --byte-subst="<0x%x>" --unicode-subst="<U+%04X>"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1053  100  1053    0     0   3477      0 --:--:-- --:--:-- --:--:--  3486
pytest-sugar
================

|Build Status| |Version Status| |Downloads|

pytest-sugar is a plugin for `py.test <http://pytest.org>`_ that shows
failures and errors instantly and shows a progress bar.

|pytest-sugar|

.. |pytest-sugar| image:: http://pivotfinland.com/pytest-sugar/img/terminal.png
   :alt: Screenshot
.. _pytest-sugar: http://pivotfinland.com/pytest-sugar/
.. |Build Status| image:: https://travis-ci.org/Frozenball/pytest-sugar.png?branch=master
   :target: https://travis-ci.org/Frozenball/pytest-sugar
.. |Version Status| image:: https://pypip.in/v/pytest-sugar/badge.png
   :target: https://crate.io/packages/pytest-sugar/
.. |Downloads| image:: https://pypip.in/d/pytest-sugar/badge.png
   :target: https://crate.io/packages/pytest-sugar/

Requirements
------------

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

- Python 2.6, 2.7, 3.2, 3.3 or PyPy
- pytest 2.3 or newer

Installation
------------

To install pytest-sugar::

    $<U+00A0>pip install pytest-sugar

Then run your tests with::

    $<U+00A0>py.test

Possible to make pytest-sugar not be a fork of jpvanhal/pytest-instafail?

I think folks at my work were able to reset their repos to no longer be forks by clicking a button in the repo settings in GitHub Enterprise. Presumably public GitHub has something similar?

It's a little annoying every time I submit a PR that the default target repo is jpvanhal/pytest-instafail and I have to change it.

Eventually, someone is probably going to send a PR to the wrong repo.

text dump instead of graph

I am seeing this instead of graph

\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m                                                               \x1b[32m98%...
Results (0.73s):
      85 passed

The dump is very very long. It's supposed to be rendered to graph. I am inside a docker container, what could be the reason, please? I have tested color display, it's ok. The 85 passed part is in green.

Using pytest.mark.xfail throws an error

Decorating test functions with pytest.mark.xfail should cause them to be skipped (and preferrably show some kind of a skip icon), but instead throws an error.

Example file test.py:

import pytest


@pytest.mark.xfail
def test():
    pass

Output of py.test test.py:

Test session starts (platform: darwin, Python 2.7.1, pytest 2.5.2, pytest-sugar 0.3.3)
plugins: sugar


\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015 test \u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/main.py", line 81, in wrap_session
INTERNALERROR>     doit(config, session)
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/main.py", line 118, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/core.py", line 377, in __call__
INTERNALERROR>     return self._docall(methods, kwargs)
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/core.py", line 388, in _docall
INTERNALERROR>     res = mc.execute()
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/core.py", line 289, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/main.py", line 138, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/core.py", line 377, in __call__
INTERNALERROR>     return self._docall(methods, kwargs)
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/core.py", line 388, in _docall
INTERNALERROR>     res = mc.execute()
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/core.py", line 289, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/runner.py", line 64, in pytest_runtest_protocol
INTERNALERROR>     runtestprotocol(item, nextitem=nextitem)
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/runner.py", line 74, in runtestprotocol
INTERNALERROR>     reports.append(call_and_report(item, "call", log))
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/runner.py", line 112, in call_and_report
INTERNALERROR>     hook.pytest_runtest_logreport(report=report)
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/main.py", line 162, in call_matching_hooks
INTERNALERROR>     return hookmethod.pcall(plugins, **kwargs)
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/core.py", line 381, in pcall
INTERNALERROR>     return self._docall(methods, kwargs)
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/core.py", line 388, in _docall
INTERNALERROR>     res = mc.execute()
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/core.py", line 289, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/pytest_sugar.py", line 217, in pytest_runtest_logreport
INTERNALERROR>     self.print_failure(report)
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/pytest_sugar.py", line 332, in print_failure
INTERNALERROR>     self._outrep_summary(report)
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/terminal.py", line 442, in _outrep_summary
INTERNALERROR>     rep.toterminal(self._tw)
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/_pytest/runner.py", line 177, in toterminal
INTERNALERROR>     out.line(longrepr)
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/py/_io/terminalwriter.py", line 195, in line
INTERNALERROR>     self._checkfill(s)
INTERNALERROR>   File "/Users/felix/Environments/test/lib/python2.7/site-packages/py/_io/terminalwriter.py", line 207, in _checkfill
INTERNALERROR>     diff2last = self._lastlen - len(line)
INTERNALERROR> TypeError: object of type 'NoneType' has no len()


Results (0.02s):

Output of pip freeze:

py==1.4.20
pytest==2.5.2
pytest-sugar==0.3.3
wsgiref==0.1.2

Output of py.test test.py when pytest-sugar is not installed:

============================= test session starts ==============================
platform darwin -- Python 2.7.1 -- py-1.4.20 -- pytest-2.5.2
collected 1 items

test.py X

========================== 1 xpassed in 0.01 seconds ===========================

Apparent issue with pytest 3.4.0

Pytest 3.4.0 was just released today and immediately I started seeing failing tests and lots of unfamiliar output. I wasn't sure what it was, so I started removing bits one by one, and the problem seems to go away when I disable the pytest-sugar plugin. I'm not sure whether to report this to the pytest project or the pytest-sugar project, but thought I'd start here.

Pytest-sugar is the only plugin I'm using, so perhaps it's a general problem related to all pytest plugins.

I made a project that I believe isolates the issue: https://github.com/jakewan/pytestdemo

From the README:

Create a virtual environment

From project root directory:

$ make create-virtual-env
if [ -d ".pytestdemo/env" ]; then rm -rf .pytestdemo/env; fi
python3 -m venv .pytestdemo/env
.pytestdemo/env/bin/pip install -e .
Obtaining file:///Users/jacob/Documents/repos/pytestdemo
Collecting pytest (from pytestdemo==0.1a1)
  Using cached pytest-3.4.0-py2.py3-none-any.whl
Collecting pytest-sugar (from pytestdemo==0.1a1)
  Using cached pytest-sugar-0.9.0.tar.gz
Collecting pluggy<0.7,>=0.5 (from pytest->pytestdemo==0.1a1)
Collecting attrs>=17.2.0 (from pytest->pytestdemo==0.1a1)
  Using cached attrs-17.4.0-py2.py3-none-any.whl
Collecting py>=1.5.0 (from pytest->pytestdemo==0.1a1)
  Using cached py-1.5.2-py2.py3-none-any.whl
Collecting six>=1.10.0 (from pytest->pytestdemo==0.1a1)
  Using cached six-1.11.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools in ./.pytestdemo/env/lib/python3.6/site-packages (from pytest->pytestdemo==0.1a1)
Collecting termcolor>=1.1.0 (from pytest-sugar->pytestdemo==0.1a1)
  Using cached termcolor-1.1.0.tar.gz
Installing collected packages: pluggy, attrs, py, six, pytest, termcolor, pytest-sugar, pytestdemo
  Running setup.py install for termcolor ... done
  Running setup.py install for pytest-sugar ... done
  Running setup.py develop for pytestdemo
Successfully installed attrs-17.4.0 pluggy-0.6.0 py-1.5.2 pytest-3.4.0 pytest-sugar-0.9.0 pytestdemo six-1.11.0 termcolor-1.1.0

Run the test

$ make run-tests
.pytestdemo/env/bin/py.test
Test session starts (platform: darwin, Python 3.6.4, pytest 3.4.0, pytest-sugar 0.9.0)
rootdir: /Users/jacob/Documents/repos/pytestdemo, inifile:
plugins: sugar-0.9.0

 test/test_foo.py โœ“                                                                                                                                         100% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆINTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/_pytest/main.py", line 100, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/_pytest/main.py", line 138, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/callers.py", line 76, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/callers.py", line 180, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/_pytest/main.py", line 161, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/callers.py", line 76, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/callers.py", line 180, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/_pytest/runner.py", line 64, in pytest_runtest_protocol
INTERNALERROR>     nodeid=item.nodeid, location=item.location,
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/callers.py", line 76, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/pluggy/callers.py", line 180, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/jacob/Documents/repos/pytestdemo/.pytestdemo/env/lib/python3.6/site-packages/_pytest/terminal.py", line 315, in pytest_runtest_logfinish
INTERNALERROR>     last_item = len(self._progress_nodeids_reported) == self._session.testscollected
INTERNALERROR> AttributeError: 'NoneType' object has no attribute 'testscollected'


Results (0.02s):
       1 passed
make: *** [run-tests] Error 3

Remove pytest-sugar

Update setup.py by commenting out the line requiring pytest-sugar, e.g.

install_requires=[
    'pytest',
    # 'pytest-sugar',
],

Recreate the virtual environment

$ make create-virtual-env
if [ -d ".pytestdemo/env" ]; then rm -rf .pytestdemo/env; fi
python3 -m venv .pytestdemo/env
.pytestdemo/env/bin/pip install -e .
Obtaining file:///Users/jacob/Documents/repos/pytestdemo
Collecting pytest (from pytestdemo==0.1a1)
  Using cached pytest-3.4.0-py2.py3-none-any.whl
Collecting six>=1.10.0 (from pytest->pytestdemo==0.1a1)
  Using cached six-1.11.0-py2.py3-none-any.whl
Collecting attrs>=17.2.0 (from pytest->pytestdemo==0.1a1)
  Using cached attrs-17.4.0-py2.py3-none-any.whl
Collecting pluggy<0.7,>=0.5 (from pytest->pytestdemo==0.1a1)
Requirement already satisfied: setuptools in ./.pytestdemo/env/lib/python3.6/site-packages (from pytest->pytestdemo==0.1a1)
Collecting py>=1.5.0 (from pytest->pytestdemo==0.1a1)
  Using cached py-1.5.2-py2.py3-none-any.whl
Installing collected packages: six, attrs, pluggy, py, pytest, pytestdemo
  Running setup.py develop for pytestdemo
Successfully installed attrs-17.4.0 pluggy-0.6.0 py-1.5.2 pytest-3.4.0 pytestdemo six-1.11.0

Run the test again

manzanita:pytestdemo jacob$ make run-tests
.pytestdemo/env/bin/py.test
=========================================================================== test session starts ===========================================================================
platform darwin -- Python 3.6.4, pytest-3.4.0, py-1.5.2, pluggy-0.6.0
rootdir: /Users/jacob/Documents/repos/pytestdemo, inifile:
collected 1 item

test/test_foo.py .                                                                                                                                                  [100%]

======================================================================== 1 passed in 0.01 seconds =========================================================================

Okay with --verbose

Also, in case it's relevant, the problem also goes away when I run py.test with the --verbose flag:

$ .pytestdemo/env/bin/py.test --verbose
Test session starts (platform: darwin, Python 3.6.4, pytest 3.4.0, pytest-sugar 0.9.0)
cachedir: .pytest_cache
rootdir: /Users/jacob/Documents/repos/pytestdemo, inifile:
plugins: sugar-0.9.0

 test/test_foo.py::test_foo_says โœ“                                                                                                                          100% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ

Results (0.01s):
       1 passed

Crash when doctest fails

When running pytest with --doctest-modules and if one of the doctests fails, pytest-sugar fails with a TypeError. For example, here's the invocation of tox on this repro repo:

python create: /Users/jaraco/issue-N/.tox/python
python installdeps: -rtests/requirements.txt
python develop-inst: /Users/jaraco/issue-N
python installed: ----------------------------------------,Error when trying to get requirement for VCS system Command "git config --get-regexp remote\..*\.url" failed with error code 1 in /Users/jaraco/issue-N, falling back to uneditable format,Could not determine repository location of /Users/jaraco/issue-N,appdirs==1.4.3,packaging==16.8,py==1.4.33,pyparsing==2.2.0,pytest==3.0.7,pytest-sugar==0.8.0,six==1.10.0,## !! Could not determine repository location,skeleton==0.1.dev59+g23dae90,termcolor==1.1.0
python runtests: PYTHONHASHSEED='2034398031'
python runtests: commands[0] | py.test
Test session starts (platform: darwin, Python 3.6.1, pytest 3.0.7, pytest-sugar 0.8.0)
rootdir: /Users/jaraco/issue-N, inifile: pytest.ini
plugins: sugar-0.8.0


โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€• [doctest] mod โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•
001 
002 Just a failing doctest
003 
004 >>> 1
Expected:
    0
Got:
    1

/Users/jaraco/issue-N/pkg/mod.py:4: DocTestFailure

 pkg/mod.py โจฏ                                                                      100% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ

Results (0.10s):
       1 failed
Traceback (most recent call last):
  File "/Users/jaraco/issue-N/.tox/python/bin/py.test", line 11, in <module>
    sys.exit(main())
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/config.py", line 57, in main
    return config.hook.pytest_cmdline_main(config=config)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
    res = hook_impl.function(*args)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/main.py", line 127, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/main.py", line 122, in wrap_session
    exitstatus=session.exitstatus)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
    wrap_controller.send(call_outcome)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/terminal.py", line 374, in pytest_sessionfinish
    self.summary_stats()
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/pytest_sugar.py", line 494, in summary_stats
    report.location[1] + 1,
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
ERROR: InvocationError: '/Users/jaraco/issue-N/.tox/python/bin/py.test'
____________________________________________ summary _____________________________________________
ERROR:   python: commands failed

Plugin not grouping tests by file

Hey there, this plugin is just awesome, but I'm having some dramas with it.

Unlike the demo animation, I can't seem to get it to show multiple ticks against a single test source file. I am using @pytest.mark.parametrize to run tests against multiple parameters and I wonder if this may be the problem:

image

You can check out the project I'm testing this against here.

Any help would be greatly appreciated.
Fotis

Output garbled under tox 2.x

When running under tox >= 2.0 the output shows raw escape sequences.
It might well be a tox bug but OTOH pytest's own colored output works just fine.

Example output:

py34 inst-nodeps: xxxx.zip
py34 installed: coverage==4.0a5,xxxx==1.0.0a0,flake8==2.4.1,future==0.14.3,mccabe==0.3,pep8==1.5.7,py==1.4.27,pyflakes==0.8.1,pytest==2.7.1,pytest-mock==0.5.0,pytest-sugar==0.4.0,termcolor==1.1.0,wheel==0.24.0
py34 runtests: PYTHONHASHSEED='3528495582'
py34 runtests: commands[0] | coverage run --source xxxx --branch -m py.test --junitxml=junit-py34.xml
Test session starts (platform: darwin, Python 3.4.3, pytest 2.7.1, pytest-sugar 0.4.0)
rootdir: /Users/ulo/Dropbox/devel/xxxx, inifile:
plugins: mock, sugar

\r 
\x1b[36mtests/\x1b[0mtest_config.py\x1b[0m \x1b[32m\u2713\x1b[0m                                                                                                                                                                         25% \x1b[40m\x1b[32m\u2588\u2588\u258c       \x1b[0m\r 
\x1b[36mtests/\x1b[0mtest_config.py\x1b[0m \x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m                                                                                                                                                                        50% \x1b[40m\x1b[32m\u2588\u2588\u2588\u2588\u2588     \x1b[0m\r 
\x1b[36mtests/\x1b[0mtest_config.py\x1b[0m \x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m                                                                                                                                                                       75% \x1b[40m\x1b[32m\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258c  \x1b[0m\r 
\x1b[36mtests/\x1b[0mtest_config.py\x1b[0m \x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m                                                                                                                                                                     100% \x1b[40m\x1b[32m\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\x1b[0m

(I added a linebreak after each \r to increase readability)

Pytest-sugar errors out when running with deselected test.

py.test running in python3.4 on ubuntu 14.04 with a command that deselects at least one test execution fails with a AttributeError: 'Function' object has no attribute 'when' exception after the test exeution block(NOTE: at least one test hasto be actually 'deselected', it does not matter if any run).

Running with '-p no:sugar' does fix the issue.

example bellow:

 $python3 -m pytest -m noomarker test_py.py
Test session starts (platform: linux, Python 3.4.0, pytest 2.9.1, pytest-sugar 0.7.0)
rootdir: /home/alexei, inifile: 
plugins: cpp-0.4, capturelog-0.7, sugar-0.7.0, timeout-1.0.0

================================================================================= 1 tests deselected by "-m 'noomarker'" =================================================================================

Results (0.01s):
Traceback (most recent call last):
  File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.4/dist-packages/pytest.py", line 17, in <module>
    raise SystemExit(pytest.main())
  File "/usr/local/lib/python3.4/dist-packages/_pytest/config.py", line 49, in main
    return config.hook.pytest_cmdline_main(config=config)
  File "/usr/local/lib/python3.4/dist-packages/_pytest/vendored_packages/pluggy.py", line 724, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/usr/local/lib/python3.4/dist-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/usr/local/lib/python3.4/dist-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/usr/local/lib/python3.4/dist-packages/_pytest/vendored_packages/pluggy.py", line 596, in execute
    res = hook_impl.function(*args)
  File "/usr/local/lib/python3.4/dist-packages/_pytest/main.py", line 119, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/usr/local/lib/python3.4/dist-packages/_pytest/main.py", line 114, in wrap_session
    exitstatus=session.exitstatus)
  File "/usr/local/lib/python3.4/dist-packages/_pytest/vendored_packages/pluggy.py", line 724, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/usr/local/lib/python3.4/dist-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/usr/local/lib/python3.4/dist-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/usr/local/lib/python3.4/dist-packages/_pytest/vendored_packages/pluggy.py", line 595, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File "/usr/local/lib/python3.4/dist-packages/_pytest/vendored_packages/pluggy.py", line 249, in _wrapped_call
    wrap_controller.send(call_outcome)
  File "/usr/local/lib/python3.4/dist-packages/_pytest/terminal.py", line 378, in pytest_sessionfinish
    self.summary_stats()
  File "/usr/local/lib/python3.4/dist-packages/pytest_sugar.py", line 436, in summary_stats
    if self.count('deselected') > 0:
  File "/usr/local/lib/python3.4/dist-packages/pytest_sugar.py", line 397, in count
    [x for x in self.stats.get(key) if x.when in when]
  File "/usr/local/lib/python3.4/dist-packages/pytest_sugar.py", line 397, in <listcomp>
    [x for x in self.stats.get(key) if x.when in when]
AttributeError: 'Function' object has no attribute 'when'

the code for the example test:

class TestClass:
  def test_nothing(self):
    pass

http://pivotfinland.com/pytest-sugar/ busted?

Hey @Frozenball:

I think http://pivotfinland.com/pytest-sugar/ is busted -- it's returning a 404 for me.

 โฏ curl http://pivotfinland.com/pytest-sugar/
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /pytest-sugar/ was not found on this server.</p>
<hr>
<address>Apache/2.4.6 (Ubuntu) Server at pivotfinland.com Port 80</address>
</body></html>

Tests fail with pytest 3.5.0 DOCTESTS

After updating from pytest from 3.4.2 to 3.5.0, pytest-sugar's testsuite fails:

============================= test session starts ==============================
platform linux -- Python 3.6.5, pytest-3.5.0, py-1.5.3, pluggy-0.6.0
rootdir: /build/pytest-sugar-0.9.1, inifile:
plugins: sugar-0.9.1
collected 27 items

test_sugar.py \x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m [ 11%]
\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m [ 22%]
\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m [ 33%]
\x1b[32m\u2713\x1b[0ms\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m [ 44%]
\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m [ 55%]
\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m [ 66%]
\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m [ 77%]
\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0ms\x1b[32m\u2713\x1b[0m [ 88%]
\x1b[32m\u2713\x1b[0ms\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[32m\u2713\x1b[0m\x1b[31m\u2a2f\x1b[0m\x1b[32m\u2713\x1b[0m [100%]

=================================== FAILURES ===================================
___________________ TestTerminalReporter.test_doctest_lineno ___________________

self = <test_sugar.TestTerminalReporter object at 0x7ffff0a768d0>
testdir = <Testdir local('/build/pytest-of-nixbld/pytest-0/test_doctest_lineno0')>

    def test_doctest_lineno(self, testdir):
        """ Test location reported for doctest-modules """

        testdir.makepyfile(
            """
                def foobar():
                    '''
                    >>> foobar()
                    '''
                    raise NotImplementedError
                """
        )
        result = testdir.runpytest('--force-sugar', '--doctest-module')

        assert result.ret == 1, result.stderr.str()
        result.stdout.fnmatch_lines([
            'UNEXPECTED EXCEPTION: NotImplementedError()',
            '*test_doctest_lineno.py:3: UnexpectedException',
            'Results*:',
>           '*-*test_doctest_lineno.py*:3*',
        ])

/build/pytest-sugar-0.9.1/test_sugar.py:514:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <_pytest.pytester.LineMatcher object at 0x7ffff0ccb3c8>
lines2 = ['UNEXPECTED EXCEPTION: NotImplementedError()', '*test_doctest_lineno.py:3: UnexpectedException', 'Results*:', '*-*test_doctest_lineno.py*:3*']

    def fnmatch_lines(self, lines2):
        """Search captured text for matching lines using ``fnmatch.fnmatch``.

            The argument is a list of lines which have to match and can use glob
            wildcards.  If they do not match a pytest.fail() is called.  The
            matches and non-matches are also printed on stdout.

            """
>       self._match_lines(lines2, fnmatch, 'fnmatch')
E       Failed: nomatch: 'UNEXPECTED EXCEPTION: NotImplementedError()'
E           and: 'Test session starts (platform: linux, Python 3.6.5, pytest 3.5.0, pytest-sugar 0.9.1)'
E           and: 'rootdir: /build/pytest-of-nixbld/pytest-0/test_doctest_lineno0, inifile:'
E           and: 'plugins: sugar-0.9.1'
E           and: ''
E           and: ''
E           and: '\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015 [doctest] test_doctest_lineno.foobar \u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015'
E           and: '002 '
E           and: '003                 >>> foobar()'
E       exact match: 'UNEXPECTED EXCEPTION: NotImplementedError()'
E       nomatch: '*test_doctest_lineno.py:3: UnexpectedException'
E           and: 'Traceback (most recent call last):'
E           and: ''
E           and: '  File "/nix/store/33v7rg3qmwfj3smvhna5634n7x286wl6-python3-3.6.5/lib/python3.6/doctest.py", line 1330, in __run'
E           and: '    compileflags, 1), test.globs)'
E           and: ''
E           and: '  File "<doctest test_doctest_lineno.foobar[0]>", line 1, in <module>'
E           and: ''
E           and: '  File "/build/pytest-of-nixbld/pytest-0/test_doctest_lineno0/test_doctest_lineno.py", line 5, in foobar'
E           and: '    raise NotImplementedError'
E           and: ''
E           and: 'NotImplementedError'
E           and: ''
E       fnmatch: '*test_doctest_lineno.py:3: UnexpectedException'
E          with: '/build/pytest-of-nixbld/pytest-0/test_doctest_lineno0/test_doctest_lineno.py:3: UnexpectedException'
E       nomatch: 'Results*:'
E           and: '\r'
E           and: '\\r \\x1b[36m\\x1b[0mtest_doctest_lineno.py\\x1b[0m \\x1b[31m\u2a2f\\x1b[0m                                        \\x1b[31m100% \\x1b[0m\\x1b[40m\\x1b[31m\u2588\\x1b[0m\\x1b[40m\\x1b[31m\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\\x1b[0m'
E           and: ''
E       fnmatch: 'Results*:'
E          with: 'Results (0.01s):'
E       nomatch: '*-*test_doctest_lineno.py*:3*'
E           and: '\x1b[31m       1 failed\x1b[0m'
E           and: '         - \x1b[36m\x1b[0mtest_doctest_lineno.py\x1b[0m:2 \x1b[31m[doctest] test_doctest_lineno.foobar\x1b[0m'
E           and: ''
E       remains unmatched: '*-*test_doctest_lineno.py*:3*'

/nix/store/chvgi987hbqcw7zx0q8qzbk4d1dg9mnd-python3.6-pytest-3.5.0/lib/python3.6/site-packages/_pytest/pytester.py:1175: Failed
----------------------------- Captured stdout call -----------------------------
Test session starts (platform: linux, Python 3.6.5, pytest 3.5.0, pytest-sugar 0.9.1)\nrootdir: /build/pytest-of-nixbld/pytest-0/test_doctest_lineno0, inifile:\nplugins: sugar-0.9.1\n\n\n\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015 [doctest] test_doctest_lineno.foobar \u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\u2015\n002 \n003                 >>> foobar()\nUNEXPECTED EXCEPTION: NotImplementedError()\nTraceback (most recent call last):\n\n  File "/nix/store/33v7rg3qmwfj3smvhna5634n7x286wl6-python3-3.6.5/lib/python3.6/doctest.py", line 1330, in __run\n    compileflags, 1), test.globs)\n\n  File "<doctest test_doctest_lineno.foobar[0]>", line 1, in <module>\n\n  File "/build/pytest-of-nixbld/pytest-0/test_doctest_lineno0/test_doctest_lineno.py", line 5, in foobar\n    raise NotImplementedError\n\nNotImplementedError\n\n/build/pytest-of-nixbld/pytest-0/test_doctest_lineno0/test_doctest_lineno.py:3: UnexpectedException\n\r\n\r \x1b[36m\x1b[0mtest_doctest_lineno.py\x1b[0m \x1b[31m\u2a2f\x1b[0m                                        \x1b[31m100% \x1b[0m\x1b[40m\x1b[31m\u2588\x1b[0m\x1b[40m\x1b[31m\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\x1b[0m\n\nResults (0.01s):\n\x1b[31m       1 failed\x1b[0m\n         - \x1b[36m\x1b[0mtest_doctest_lineno.py\x1b[0m:2 \x1b[31m[doctest] test_doctest_lineno.foobar\x1b[0m
================ 1 failed, 76 passed, 3 skipped in 2.16 seconds ================

when execute with --verbose only the first test name is written

example:
Test session starts (platform: linux, Python 3.4.0, pytest 2.6.3, pytest-sugar 0.3.4)
plugins: sugar, pycharm

eft/ut/test_logger.py::TestLoggerInit::test_basic
eft/ut/test_logger.py โœ“ 33% โ–‰โ–‰โ–‰โ–โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰
eft/ut/test_logger.py โœ“โœ“ 67% โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‹โ–‰โ–‰โ–‰โ–‰
eft/ut/test_logger.py โœ“โœ“โœ“ 100% โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰โ–‰

Results (0.06s):

3 passed

as seen only the first test name is written
in addition it will be nice if the test name will be written in the same line as the module & test status

Teardown errors not shown in summary

With this test_foo.py:

import pytest


@pytest.yield_fixture
def fixt():
    yield
    raise Exception


def test_foo(fixt):
    pass

When running normally I get:

test_foo.py .E

=================================================== ERRORS ===================================================
_______________________________________ ERROR at teardown of test_foo ________________________________________

    @pytest.yield_fixture
    def fixt():
        yield
>       raise Exception
E       Exception

test_foo.py:7: Exception
===================================== 1 passed, 1 error in 0.01 seconds ======================================

With pytest-sugar:

โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€• ERROR at teardown of test_foo โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•

    @pytest.yield_fixture
    def fixt():
        yield
>       raise Exception
E       Exception

test_foo.py:7: Exception
 test_foo.py โœ“                                                                                 100% โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ

Results (0.01s):
       1 passed

This is with 0.4.0 and pytest 2.7.3.

Add version 0.9.1 to conda-forge

Hi there,

pytest-sugar is great! Thank you for maintaining it.

Can you please update the version of pytest-sugar on conda-forge? It only has version 0.9.0.

Cheers

Max

AttributeError when used with pytest 3.4.0

I can't quite tell if this is an issue with this package or pluggy, but adding this package is when the error shows up. This error did not manifest in pytest <3.4.0.

When reporting an issue, include a way to reproduce the bug. For example:

Command used to run py.test

Tox trigger:
tox -re py27-local

Actually runs:
pytest --cov aws_encryption_sdk_cli -m local -l

Test file

https://github.com/awslabs/aws-encryption-sdk-cli/tree/master/test

Output

186590df9307:aws-encryption-sdk-cli bullocm$ tox -re py27-local
GLOB sdist-make: /Users/bullocm/git/aws-encryption-sdk-cli/setup.py
py27-local recreate: /Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local
py27-local installdeps: mock, pytest>3.3.0, pytest-cov, pytest-mock, pytest-sugar
py27-local inst: /Users/bullocm/git/aws-encryption-sdk-cli/.tox/dist/aws-encryption-sdk-cli-1.1.4.zip
py27-local installed: asn1crypto==0.24.0,attrs==17.4.0,aws-encryption-sdk==1.3.3,aws-encryption-sdk-cli==1.1.4,boto3==1.5.22,botocore==1.8.36,cffi==1.11.4,coverage==4.4.2,cryptography==2.1.4,docutils==0.14,enum34==1.1.6,funcsigs==1.0.2,futures==3.2.0,idna==2.6,ipaddress==1.0.19,jmespath==0.9.3,mock==2.0.0,pbr==3.1.1,pluggy==0.6.0,py==1.5.2,pycparser==2.18,pytest==3.4.0,pytest-cov==2.5.1,pytest-mock==1.6.3,pytest-sugar==0.9.0,python-dateutil==2.6.1,s3transfer==0.1.12,six==1.11.0,termcolor==1.1.0,typing==3.6.4,wrapt==1.10.11
py27-local runtests: PYTHONHASHSEED='3679247349'
py27-local runtests: commands[0] | pytest -m local -l
Test session starts (platform: darwin, Python 2.7.13, pytest 3.4.0, pytest-sugar 0.9.0)
rootdir: /Users/bullocm/git/aws-encryption-sdk-cli, inifile: setup.cfg
plugins: sugar-0.9.0, mock-1.6.3, cov-2.5.1

 test/unit/test_arg_parsing.py โœ“                                                                                                                                                                    0%           INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/_pytest/main.py", line 100, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/_pytest/main.py", line 138, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/callers.py", line 77, in get_result
INTERNALERROR>     _reraise(*ex)  # noqa
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/callers.py", line 180, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/_pytest/main.py", line 161, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/callers.py", line 77, in get_result
INTERNALERROR>     _reraise(*ex)  # noqa
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/callers.py", line 180, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/_pytest/runner.py", line 64, in pytest_runtest_protocol
INTERNALERROR>     nodeid=item.nodeid, location=item.location,
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/__init__.py", line 617, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/__init__.py", line 222, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/__init__.py", line 216, in <lambda>
INTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/callers.py", line 201, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/callers.py", line 77, in get_result
INTERNALERROR>     _reraise(*ex)  # noqa
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/pluggy/callers.py", line 180, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/lib/python2.7/site-packages/_pytest/terminal.py", line 315, in pytest_runtest_logfinish
INTERNALERROR>     last_item = len(self._progress_nodeids_reported) == self._session.testscollected
INTERNALERROR> AttributeError: 'NoneType' object has no attribute 'testscollected'

============================================================================================== 36 tests deselected ==============================================================================================

Results (0.57s):
       1 passed
      36 deselected
ERROR: InvocationError: '/Users/bullocm/git/aws-encryption-sdk-cli/.tox/py27-local/bin/pytest -m local -l'
____________________________________________________________________________________________________ summary ____________________________________________________________________________________________________
ERROR:   py27-local: commands failed

pytest-sugar does not honor the 'startdir' parameter from pytest_report_header

Please see reference to this issue originally filed in pytest-selenium.

$ py.test
Test session starts (platform: darwin, Python 3.5.2, pytest 3.0.2, pytest-sugar 0.7.1)
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/jon/.virtualenvs/example/lib/python3.5/site-packages/_pytest/main.py", line 94, in wrap_session
INTERNALERROR>     config.hook.pytest_sessionstart(session=session)
INTERNALERROR>   File "/Users/jon/.virtualenvs/example/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 724, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/jon/.virtualenvs/example/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/jon/.virtualenvs/example/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/Users/jon/.virtualenvs/example/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 596, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/jon/.virtualenvs/example/lib/python3.5/site-packages/pytest_sugar.py", line 217, in pytest_sessionstart
INTERNALERROR>     lines = self.config.hook.pytest_report_header(config=self.config)
INTERNALERROR>   File "/Users/jon/.virtualenvs/example/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 724, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/Users/jon/.virtualenvs/example/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/jon/.virtualenvs/example/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/Users/jon/.virtualenvs/example/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 593, in execute
INTERNALERROR>     args = [all_kwargs[argname] for argname in hook_impl.argnames]
INTERNALERROR>   File "/Users/jon/.virtualenvs/example/lib/python3.5/site-packages/_pytest/vendored_packages/pluggy.py", line 593, in <listcomp>
INTERNALERROR>     args = [all_kwargs[argname] for argname in hook_impl.argnames]
INTERNALERROR> KeyError: 'startdir'

Here's an example project, with the second commit solving the issue by removing pytest-sugar.

To reproduce, pip install -r requirements/test.txt && pip install -r requirements/local.txt, then py.test

I also had to properly space line 49 in /Users/jon/.virtualenvs/example/lib/python3.5/site-packages/selenium/webdriver/safari/webdriver.py to fall under the if statement, per this commit.

Per @nicoddemus,

pytest_report_header received a startdir parameter in 2.3.0:

pytest_report_header now receives a "startdir" so that you can use startdir.bestrelpath(yourpath) to show nice relative path

and pytest-sugar doesn't honor that.

Pass/fail summary not viewable when using xdist

I'm using pytest-xdist to run tests in parallel. The summary output at the end of a test run is much longer when using xdist than when running tests normally. The output is being truncated such that I can't read the failure messages.

Normal output without xdist:

       1 failed
         - /code/summit/summit/test/base.py:223: AssertionError: '12' != ''

Output when running with xdist:

       1 failed
         - self = <summit.test.simple.SimpleFunctionalTest te

Is there someway to increase this value in settings?

Possible to convert live video into animated GIF?

I wonder if the cool animated video at http://pivotfinland.com/pytest-sugar/

could be converted to an animated GIF?

Because GitHub, as far as I can tell, won't let us embed a video in a README, but you can embed an animated GIF and that would let the GitHub page have the sexy video.

I think I tried to convert it myself using one or two Web sites and it crapped out (maybe because it's too large?) Maybe it could be done with some desktop tool though?

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.