From 047816f33adcdd921ad2de9a792c34c93cb60e04 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 5 Aug 2020 19:45:08 -0300 Subject: [PATCH] Drop features from old pytest versions --- src/xdist/dsession.py | 5 ---- src/xdist/remote.py | 14 ----------- testing/acceptance_test.py | 48 +++----------------------------------- 3 files changed, 3 insertions(+), 64 deletions(-) diff --git a/src/xdist/dsession.py b/src/xdist/dsession.py index d7ccb8c..07ef091 100644 --- a/src/xdist/dsession.py +++ b/src/xdist/dsession.py @@ -268,11 +268,6 @@ class DSession: assert not rep.passed self._failed_worker_collectreport(node, rep) - def worker_logwarning(self, message, code, nodeid, fslocation): - """Emitted when a node calls the pytest_logwarning hook.""" - kwargs = dict(message=message, code=code, nodeid=nodeid, fslocation=fslocation) - self.config.hook.pytest_logwarning.call_historic(kwargs=kwargs) - def worker_warning_captured(self, warning_message, when, item): """Emitted when a node calls the pytest_warning_captured hook (deprecated in 6.0).""" kwargs = dict(warning_message=warning_message, when=when, item=item) diff --git a/src/xdist/remote.py b/src/xdist/remote.py index 2df96fa..3d1b246 100644 --- a/src/xdist/remote.py +++ b/src/xdist/remote.py @@ -125,20 +125,6 @@ class WorkerInteractor: ) self.sendevent("collectreport", data=data) - # the pytest_logwarning hook was deprecated since pytest 4.0 - if hasattr( - _pytest.hookspec, "pytest_logwarning" - ) and not _pytest.hookspec.pytest_logwarning.pytest_spec.get("warn_on_impl"): - - def pytest_logwarning(self, message, code, nodeid, fslocation): - self.sendevent( - "logwarning", - message=message, - code=code, - nodeid=nodeid, - fslocation=str(fslocation), - ) - # the pytest_warning_recorded hook was introduced in pytest 6.0 if hasattr(_pytest.hookspec, "pytest_warning_recorded"): diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 5b19ee6..ccb1f4d 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1,6 +1,5 @@ import os import re -import textwrap import py import pytest @@ -114,9 +113,6 @@ class TestDistribution: assert result.ret == 2 result.stdout.fnmatch_lines(["*Interrupted: stopping*1*", "*1 failed*"]) - @pytest.mark.xfail( - reason="#527: Python 3.8 failure in pytest where testdir.tmpdir returns an unexpected value" - ) def test_basetemp_in_subprocesses(self, testdir): p1 = testdir.makepyfile( """ @@ -674,32 +670,6 @@ def test_skipping(testdir): result.stdout.fnmatch_lines(["*hello*", "*1 skipped*"]) -def test_issue34_pluginloading_in_subprocess(testdir): - import _pytest.hookspec - - if not hasattr(_pytest.hookspec, "pytest_namespace"): - pytest.skip("this pytest version no longer supports pytest_namespace()") - - testdir.tmpdir.join("plugin123.py").write( - textwrap.dedent( - """ - def pytest_namespace(): - return {'sample_variable': 'testing'} - """ - ) - ) - testdir.makepyfile( - """ - import pytest - def test_hello(): - assert pytest.sample_variable == "testing" - """ - ) - result = testdir.runpytest_subprocess("-n1", "-p", "plugin123") - assert result.ret == 0 - result.stdout.fnmatch_lines(["*1 passed*"]) - - def test_fixture_scope_caching_issue503(testdir): p1 = testdir.makepyfile( """ @@ -777,27 +747,15 @@ def test_sub_plugins_disabled(testdir, plugin): class TestWarnings: @pytest.mark.parametrize("n", ["-n0", "-n1"]) - @pytest.mark.parametrize("warn_type", ["pytest", "builtin"]) - def test_warnings(self, testdir, n, request, warn_type): - if warn_type == "builtin": - warn_code = """warnings.warn(UserWarning('this is a warning'))""" - elif warn_type == "pytest": - if not hasattr(request.config, "warn"): - pytest.skip("config.warn has been removed in pytest 4.1") - warn_code = """request.config.warn('', 'this is a warning', - fslocation=py.path.local())""" - else: - assert False + def test_warnings(self, testdir, n): testdir.makepyfile( """ import warnings, py, pytest @pytest.mark.filterwarnings('ignore:config.warn has been deprecated') def test_func(request): - {warn_code} - """.format( - warn_code=warn_code - ) + warnings.warn(UserWarning('this is a warning')) + """ ) result = testdir.runpytest(n) result.stdout.fnmatch_lines(["*this is a warning*", "*1 passed, 1 warning*"])