72 lines
2.4 KiB
Diff
72 lines
2.4 KiB
Diff
|
From c89ba6bb4458704f47e08d3f2fcc7cf0ebb8f9da Mon Sep 17 00:00:00 2001
|
||
|
From: Adam Johnson <me@adamj.eu>
|
||
|
Date: Mon, 27 Jul 2020 12:06:57 +0100
|
||
|
Subject: [PATCH] Fix deprecation warnings in tests (#281)
|
||
|
|
||
|
---
|
||
|
tests/test_pytest_randomly.py | 20 +++++++++++++-------
|
||
|
tox.ini | 2 +-
|
||
|
2 files changed, 14 insertions(+), 8 deletions(-)
|
||
|
|
||
|
diff --git a/tests/test_pytest_randomly.py b/tests/test_pytest_randomly.py
|
||
|
index 817d6ad..07cb646 100644
|
||
|
--- a/tests/test_pytest_randomly.py
|
||
|
+++ b/tests/test_pytest_randomly.py
|
||
|
@@ -121,7 +121,7 @@ def test_a():
|
||
|
out.stderr.fnmatch_lines(
|
||
|
[
|
||
|
(
|
||
|
- "pytest: error: argument --randomly-seed: 'invalidvalue' "
|
||
|
+ "*: error: argument --randomly-seed: 'invalidvalue' "
|
||
|
+ "is not an integer or the string 'last'"
|
||
|
)
|
||
|
]
|
||
|
@@ -439,8 +439,8 @@ def collect(self):
|
||
|
|
||
|
|
||
|
class NoOpItem(pytest.Item):
|
||
|
- def __init__(self, path, parent, module=None):
|
||
|
- super(NoOpItem, self).__init__(path, parent)
|
||
|
+ def __init__(self, name, parent, module=None):
|
||
|
+ super(NoOpItem, self).__init__(name=name, parent=parent)
|
||
|
if module is not None:
|
||
|
self.module = module
|
||
|
|
||
|
@@ -451,13 +451,19 @@ def runtest(self):
|
||
|
def pytest_collect_file(path, parent):
|
||
|
if not str(path).endswith('.py'):
|
||
|
return
|
||
|
- return MyCollector(
|
||
|
+ return MyCollector.from_parent(
|
||
|
+ parent=parent,
|
||
|
fspath=str(path),
|
||
|
items=[
|
||
|
- NoOpItem(str(path), parent, 'foo'),
|
||
|
- NoOpItem(str(path), parent),
|
||
|
+ NoOpItem.from_parent(
|
||
|
+ name=str(path) + "1",
|
||
|
+ parent=parent, module="foo"
|
||
|
+ ),
|
||
|
+ NoOpItem.from_parent(
|
||
|
+ name=str(path) + "2",
|
||
|
+ parent=parent,
|
||
|
+ ),
|
||
|
],
|
||
|
- parent=parent,
|
||
|
)
|
||
|
"""
|
||
|
)
|
||
|
diff --git a/tox.ini b/tox.ini
|
||
|
index 1dcee71..91722a8 100644
|
||
|
--- a/tox.ini
|
||
|
+++ b/tox.ini
|
||
|
@@ -13,7 +13,7 @@ python =
|
||
|
3.9: py39
|
||
|
|
||
|
[testenv]
|
||
|
-commands = pytest -p no:randomly {posargs}
|
||
|
+commands = python -W error::DeprecationWarning -W error::PendingDeprecationWarning -m pytest -p no:randomly {posargs}
|
||
|
|
||
|
[testenv:py35]
|
||
|
deps = -rrequirements/py35.txt
|