Skip to content

Commit

Permalink
Fix support for pytest >= 3.10 (#160)
Browse files Browse the repository at this point in the history
Regards #133
Fixes #159
  • Loading branch information
Natim authored and blueyed committed Nov 7, 2018
1 parent e8cb804 commit 1d89359
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
11 changes: 11 additions & 0 deletions .coveragerc
@@ -0,0 +1,11 @@
[run]
branch = 1
parallel = 1

[report]
include = pytest_sugar.py,test_*.py

[paths]
source = ./
.tox/*/lib/python*/site-packages/
.tox\*\Lib\site-packages\
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -3,4 +3,5 @@
.tox
.cache
dist/
build
build
.coverage
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -21,6 +21,7 @@ env:
- TOXENV=py35-pytest34-supported-xdist
- TOXENV=py36-pytest30-supported-xdist
- TOXENV=py36-pytest34-supported-xdist
- TOXENV=py36-pytest310-supported-xdist-rerunfailures
- TOXENV=py35-pytest30-unsupported-xdist
- TOXENV=pypy-pytest30-supported-xdist
- TOXENV=pypy-pytest31-supported-xdist
Expand Down
16 changes: 10 additions & 6 deletions pytest_sugar.py
Expand Up @@ -14,6 +14,7 @@
import os
import re
import sys
from packaging.version import parse

try:
from configparser import ConfigParser
Expand Down Expand Up @@ -398,12 +399,10 @@ def pytest_runtest_logstart(self, nodeid, location):
# show the module_name & in verbose mode the test name.
pass

if pytest.__version__ >= '3.4':

def pytest_runtest_logfinish(self):
# prevent the default implementation to try to show
# pytest's default progress
pass
def pytest_runtest_logfinish(self):
# prevent the default implementation to try to show
# pytest's default progress
pass

def report_key(self, report):
"""Returns a key to identify which line the report should write to."""
Expand Down Expand Up @@ -625,3 +624,8 @@ def print_failure(self, report):
self.write_sep("―", msg)
self._outrep_summary(report)
self.reset_tracked_lines()


# On older version of Pytest, allow default progress
if parse(pytest.__version__) <= parse('3.4'): # pragma: no cover
del SugarTerminalReporter.pytest_runtest_logfinish
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -38,7 +38,7 @@ def get_version(filename):
zip_safe=False,
include_package_data=True,
platforms='any',
install_requires=['pytest>=2.9', 'termcolor>=1.1.0'],
install_requires=['pytest>=2.9', 'termcolor>=1.1.0', 'packaging>=14.1'],
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
Expand Down
5 changes: 3 additions & 2 deletions tox.ini
Expand Up @@ -20,12 +20,13 @@ deps =
pytest34: pytest>=3.4,<3.5
pytest37: pytest>=3.7,<3.8
pytest39: pytest>=3.9,<3.10
pytest310: pytest>=3.10,<3.11
termcolor>=1.1.0
supported-xdist: pytest-xdist>=1.14
unsupported-xdist: pytest-xdist<1.14
pytest-rerunfailures
rerunfailures: pytest-rerunfailures
commands =
py.test --cov=./ {posargs:test_sugar.py}
py.test --cov --cov-config=.coveragerc {posargs:test_sugar.py}
codecov -e TOXENV

[testenv:qa]
Expand Down

0 comments on commit 1d89359

Please sign in to comment.