Skip to content

Commit 71c2d6b

Browse files
author
Sylvain MARIE
committed
Suppressed warnings in our own tests, to improve packaging maintenance. Fixed #248
1 parent b55ce65 commit 71c2d6b

File tree

5 files changed

+37
-9
lines changed

5 files changed

+37
-9
lines changed

setup.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ test = pytest
100100
# pytest default configuration
101101
[tool:pytest]
102102
testpaths = tests/
103+
markers =
104+
black: dummy mark.
105+
fast: dummy mark.
106+
slow: dummy mark.
107+
foo: dummy mark.
108+
bar: dummy mark.
103109
addopts =
104110
--verbose
105111
--doctest-modules

tests/cases/doc/test_doc_get_current_case_id.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import pytest
2+
13
from pytest_cases import parametrize_with_cases, fixture, get_current_case_id
24

35

@@ -7,12 +9,14 @@ def data_b():
79

810
@parametrize_with_cases("data", cases=data_b, prefix="data_")
911
def test_lazy_val_case(data, request):
10-
assert get_current_case_id(request, "data") == "b"
12+
with pytest.warns(UserWarning):
13+
assert get_current_case_id(request, "data") == "b"
1114

1215

1316
@parametrize_with_cases("data,data2", cases=data_b, prefix="data_")
1417
def test_lazy_val_case_2_args(data, data2, request):
15-
assert get_current_case_id(request, ["data", "data2"]) == "b"
18+
with pytest.warns(UserWarning):
19+
assert get_current_case_id(request, ["data", "data2"]) == "b"
1620

1721

1822
@fixture
@@ -26,9 +30,11 @@ def data_a(a):
2630

2731
@parametrize_with_cases("data", cases=data_a, prefix="data_")
2832
def test_fixture_case(data, request):
29-
assert get_current_case_id(request.node, "data") == "a"
33+
with pytest.warns(UserWarning):
34+
assert get_current_case_id(request.node, "data") == "a"
3035

3136

3237
@parametrize_with_cases("data,data2", cases=data_a, prefix="data_")
3338
def test_fixture_case_2_args(data, data2, request):
34-
assert get_current_case_id(request.node, "data,data2") == "a"
39+
with pytest.warns(UserWarning):
40+
assert get_current_case_id(request.node, "data,data2") == "a"

tests/pytest_extension/fixtures/fixture_unions/test_fixture_closure_edits.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# + All contributors to <https://github.com/smarie/python-pytest-cases>
33
#
44
# License: 3-clause BSD, <https://github.com/smarie/python-pytest-cases/blob/master/LICENSE>
5+
import warnings
6+
57
from copy import copy
68

79
import pytest
@@ -21,7 +23,10 @@ def test_issue116(request):
2123
normal_closure.remove('a')
2224

2325

24-
b = fixture_union('b', [a, a])
26+
with warnings.catch_warnings():
27+
# ignore the warning about the two values being the same fixture.
28+
warnings.simplefilter("ignore")
29+
b = fixture_union('b', [a, a])
2530

2631

2732
super_closure = None

tests/pytest_extension/issues/test_issue_fixture_union1.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# + All contributors to <https://github.com/smarie/python-pytest-cases>
33
#
44
# License: 3-clause BSD, <https://github.com/smarie/python-pytest-cases/blob/master/LICENSE>
5-
from distutils.version import LooseVersion
5+
import warnings
66

77
import pytest
88

@@ -15,7 +15,10 @@ def a():
1515
return 1
1616

1717

18-
u = fixture_union("u", (a, a))
18+
with warnings.catch_warnings():
19+
# ignore the warning about the two values being the same fixture.
20+
warnings.simplefilter("ignore")
21+
u = fixture_union("u", (a, a))
1922

2023

2124
def test_foo(u):

tests/pytest_extension/issues/test_issue_fixture_union2.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# + All contributors to <https://github.com/smarie/python-pytest-cases>
33
#
44
# License: 3-clause BSD, <https://github.com/smarie/python-pytest-cases/blob/master/LICENSE>
5+
import warnings
6+
57
import pytest
68

79
from pytest_cases.common_pytest_marks import PYTEST3_OR_GREATER
@@ -18,14 +20,20 @@ def b():
1820
return 1
1921

2022

21-
u = fixture_union("u", (a, b, a), ids=['1', '2', '3'])
23+
with warnings.catch_warnings():
24+
# ignore the warning about the two values being the same fixture.
25+
warnings.simplefilter("ignore")
26+
u = fixture_union("u", (a, b, a), ids=['1', '2', '3'])
2227

2328

2429
def test_foo(u):
2530
pass
2631

2732

28-
v = fixture_union("v", (a, b, a))
33+
with warnings.catch_warnings():
34+
# ignore the warning about the two values being the same fixture.
35+
warnings.simplefilter("ignore")
36+
v = fixture_union("v", (a, b, a))
2937

3038

3139
def test_foo2(v):

0 commit comments

Comments
 (0)