-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Pytest warnings #10
Conversation
1571429
to
a3d7e8d
Compare
As of 5.4.0 Pytest emits deprecation warnings [0]: ``` PytestDeprecationWarning: direct construction of Spec* has been deprecated, please use Spec*.from_parent. ``` [0]: https://docs.pytest.org/en/5.4.0/changelog.html#deprecations Signed-off-by: Stanislav Levin <slev@altlinux.org>
As of 5.3.0 Pytest improved colored statistics of the outcome: https://docs.pytest.org/en/5.3.0/changelog.html#improvements Signed-off-by: Stanislav Levin <slev@altlinux.org>
a3d7e8d
to
6360ba2
Compare
Looks like something is wrong with that PR. + /usr/bin/pytest -ra -p no:flaky
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.11, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /home/tkloczko/rpmbuild/BUILD/pytest-forked-1.3.0, configfile: tox.ini
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, case-1.5.3, aspectlib-1.5.2, toolbox-0.5, mock-3.6.1, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, pyfakefs-4.5.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, cases-3.6.3, xprocess-0.18.1, black-0.3.12, checkdocs-2.7.1, anyio-3.3.0, Faker-8.11.0, asyncio-0.15.1, trio-0.7.0, httpbin-1.0.0, subtests-0.5.0, relaxed-1.1.5, isort-2.0.0, hypothesis-6.14.6
collected 13 items / 1 error / 12 selected
================================================================================== ERRORS ==================================================================================
________________________________________________________________________ ERROR collecting setup.py _________________________________________________________________________
/usr/lib64/python3.8/distutils/fancy_getopt.py:233: in getopt
opts, args = getopt.getopt(args, short_opts, self.long_opts)
/usr/lib64/python3.8/getopt.py:95: in getopt
opts, args = do_shorts(opts, args[0][1:], shortopts, args[1:])
/usr/lib64/python3.8/getopt.py:195: in do_shorts
if short_has_arg(opt, shortopts):
/usr/lib64/python3.8/getopt.py:211: in short_has_arg
raise GetoptError(_('option -%s not recognized') % opt, opt)
E getopt.GetoptError: option -r not recognized
During handling of the above exception, another exception occurred:
/usr/lib64/python3.8/distutils/core.py:134: in setup
ok = dist.parse_command_line()
/usr/lib64/python3.8/distutils/dist.py:475: in parse_command_line
args = parser.getopt(args=self.script_args, object=self)
/usr/lib64/python3.8/distutils/fancy_getopt.py:235: in getopt
raise DistutilsArgError(msg)
E distutils.errors.DistutilsArgError: option -r not recognized
During handling of the above exception, another exception occurred:
setup.py:3: in <module>
setup(
/usr/lib/python3.8/site-packages/setuptools/__init__.py:144: in setup
return distutils.core.setup(**attrs)
/usr/lib64/python3.8/distutils/core.py:136: in setup
raise SystemExit(gen_usage(dist.script_name) + "\nerror: %s" % msg)
E SystemExit: usage: pytest [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
E or: pytest --help [cmd1 cmd2 ...]
E or: pytest --help-commands
E or: pytest cmd --help
E
E error: option -r not recognized
========================================================================= short test summary info ==========================================================================
ERROR setup.py - SystemExit: usage: pytest [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================= 1 error in 0.47s ============================================================================= |
Just checked what is inside that patch and I found at the end as well hardcoding terminal sequences @@ -225,7 +228,14 @@ def behavior_four(self):
assert "== FAILURES ==" in output
assert "AssertionError" in output
# Summary
- assert "== 1 failed, 4 passed, 1 skipped in " in output
+ if pytest_version_info >= (5, 3):
+ expected_out = (
+ "== \x1b[31m\x1b[1m1 failed\x1b[0m, \x1b[32m4 passed\x1b[0m, "
+ "\x1b[33m1 skipped\x1b[0m\x1b[31m in "
+ )
+ else:
+ expected_out = "== 1 failed, 4 passed, 1 skipped in "
+ assert expected_out in output
def test_nests_many_levels_deep_no_problem(self, testdir):
testdir.makepyfile( I'm almost sure that this will not work and will produce messy output on for example mono terminals. I'm not sure how it will be on Windows cmd but probably it will not work as well |
This should be fixed as of the latest major release! |
Just tested 2.0.0 andI see one + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-relaxed-2.0.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-relaxed-2.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.16, pytest-7.2.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/pytest-relaxed-2.0.0, configfile: pytest.ini, testpaths: tests
plugins: relaxed-2.0.0, timeout-2.1.0, xdist-3.1.0
collected 33 items
tests/test_collection.py .............s....... [ 63%]
tests/test_display.py .s....... [ 90%]
tests/test_raises.py ... [100%]
===================================================================================== warnings summary ======================================================================================
tests/test_collection.py: 20 warnings
tests/test_display.py: 5 warnings
/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-relaxed-2.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/pytest_relaxed/plugin.py:40: PytestDeprecationWarning: The hookimpl pytest_configure uses old-style configuration options (marks or attributes).
Please use the pytest.hookimpl(trylast=True) decorator instead
to configure the hooks.
See https://docs.pytest.org/en/latest/deprecations.html#configuring-hook-specs-impls-using-markers
@pytest.mark.trylast # So we can be sure builtin terminalreporter exists
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================== short test summary info ==================================================================================
SKIPPED [1] tests/test_collection.py:340: unconditional skip
SKIPPED [1] tests/test_display.py:64: Skipped
======================================================================== 31 passed, 2 skipped, 25 warnings in 3.25s ========================================================================= |
As of 5.3.0 Pytest improved colored statistics of the outcome:
https://docs.pytest.org/en/5.3.0/changelog.html#improvements
As of 5.4.0 Pytest emits deprecation warnings:
https://docs.pytest.org/en/5.4.0/changelog.html#deprecations