Skip to content

Commit 101efbc

Browse files
committed
Merge branch 'automark' into develop
2 parents 4cf2e79 + 686055b commit 101efbc

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

doc/src/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ dev (not yet released)
55
Bug fixes and minor changes
66
+ `#40`_: add logging.
77
+ `#50`_, `#51`_: test suite incompatibility with pytest 6.2.0.
8+
+ `#58`_: declare the type of automark_dependency ini-option
9+
correctly as bool.
810

911
.. _#40: https://github.com/RKrahl/pytest-dependency/issues/40
1012
.. _#50: https://github.com/RKrahl/pytest-dependency/issues/50
1113
.. _#51: https://github.com/RKrahl/pytest-dependency/pull/51
14+
.. _#58: https://github.com/RKrahl/pytest-dependency/pull/58
1215

1316
0.5.1 (2020-02-14)
1417
Bug fixes and minor changes

src/pytest_dependency.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,6 @@
1111
_ignore_unknown = False
1212

1313

14-
def _get_bool(value):
15-
"""Evaluate string representation of a boolean value.
16-
"""
17-
if value:
18-
if value.lower() in ["0", "no", "n", "false", "f", "off"]:
19-
return False
20-
elif value.lower() in ["1", "yes", "y", "true", "t", "on"]:
21-
return True
22-
else:
23-
raise ValueError("Invalid truth value '%s'" % value)
24-
else:
25-
return False
26-
27-
2814
class DependencyItemStatus(object):
2915
"""Status of a test item in a dependency manager.
3016
"""
@@ -142,15 +128,15 @@ def depends(request, other, scope='module'):
142128
def pytest_addoption(parser):
143129
parser.addini("automark_dependency",
144130
"Add the dependency marker to all tests automatically",
145-
default=False)
131+
type="bool", default=False)
146132
parser.addoption("--ignore-unknown-dependency",
147133
action="store_true", default=False,
148134
help="ignore dependencies whose outcome is not known")
149135

150136

151137
def pytest_configure(config):
152138
global _automark, _ignore_unknown
153-
_automark = _get_bool(config.getini("automark_dependency"))
139+
_automark = config.getini("automark_dependency")
154140
_ignore_unknown = config.getoption("--ignore-unknown-dependency")
155141
config.addinivalue_line("markers",
156142
"dependency(name=None, depends=[]): "

tests/test_04_automark.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ def test_b():
2929
""")
3030

3131

32-
def test_set_false(ctestdir):
32+
@pytest.mark.parametrize(
33+
"false_value", ["0", "no", "n", "False", "false", "f", "off"]
34+
)
35+
def test_set_false(ctestdir, false_value):
3336
"""A pytest.ini is present, automark_dependency is set to false.
3437
3538
Since automark_dependency is set to false and test_a is not
@@ -38,9 +41,9 @@ def test_set_false(ctestdir):
3841
"""
3942
ctestdir.makefile('.ini', pytest="""
4043
[pytest]
41-
automark_dependency = false
44+
automark_dependency = %s
4245
console_output_style = classic
43-
""")
46+
""" % false_value)
4447
ctestdir.makepyfile("""
4548
import pytest
4649
@@ -59,7 +62,10 @@ def test_b():
5962
""")
6063

6164

62-
def test_set_true(ctestdir):
65+
@pytest.mark.parametrize(
66+
"true_value", ["1", "yes", "y", "True", "true", "t", "on"]
67+
)
68+
def test_set_true(ctestdir, true_value):
6369
"""A pytest.ini is present, automark_dependency is set to false.
6470
6571
Since automark_dependency is set to true, the outcome of test_a
@@ -68,9 +74,9 @@ def test_set_true(ctestdir):
6874
"""
6975
ctestdir.makefile('.ini', pytest="""
7076
[pytest]
71-
automark_dependency = true
77+
automark_dependency = %s
7278
console_output_style = classic
73-
""")
79+
""" % true_value)
7480
ctestdir.makepyfile("""
7581
import pytest
7682

0 commit comments

Comments
 (0)