Skip to content

Commit f6bfa5c

Browse files
committed
Declare the type of the automark_dependency ini-option as bool, rather
than trying to parse boolean from a string value
1 parent 0667826 commit f6bfa5c

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

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=[]): "

0 commit comments

Comments
 (0)