summaryrefslogtreecommitdiff
path: root/_pytest/compat.py
diff options
context:
space:
mode:
authorBruno Oliveira <nicoddemus@gmail.com>2016-08-17 22:50:10 -0300
committerBruno Oliveira <nicoddemus@gmail.com>2016-08-17 22:50:10 -0300
commit3ba475c0f25b57c25f594429186b873c2c7fdbbe (patch)
tree80712cd06b4e22921c3c7e6fceb388544e653e1c /_pytest/compat.py
parent463e6572c5eb794eea32459231e5f0df1bb5ad44 (diff)
downloadpytest-3ba475c0f25b57c25f594429186b873c2c7fdbbe.tar.gz
Move internal _is_unittest_unexpected_success_a_failure to "compat" module
Fix #1815
Diffstat (limited to '_pytest/compat.py')
-rw-r--r--_pytest/compat.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/_pytest/compat.py b/_pytest/compat.py
index 1a2f1e24a..23e3b8b92 100644
--- a/_pytest/compat.py
+++ b/_pytest/compat.py
@@ -173,6 +173,7 @@ def get_real_func(obj):
obj = obj.func
return obj
+
def getfslineno(obj):
# xxx let decorators etc specify a sane ordering
obj = get_real_func(obj)
@@ -182,6 +183,7 @@ def getfslineno(obj):
assert isinstance(fslineno[1], int), obj
return fslineno
+
def getimfunc(func):
try:
return func.__func__
@@ -191,6 +193,7 @@ def getimfunc(func):
except AttributeError:
return func
+
def safe_getattr(object, name, default):
""" Like getattr but return default upon any Exception.
@@ -201,3 +204,15 @@ def safe_getattr(object, name, default):
return getattr(object, name, default)
except Exception:
return default
+
+
+def _is_unittest_unexpected_success_a_failure():
+ """Return if the test suite should fail if a @expectedFailure unittest test PASSES.
+
+ From https://docs.python.org/3/library/unittest.html?highlight=unittest#unittest.TestResult.wasSuccessful:
+ Changed in version 3.4: Returns False if there were any
+ unexpectedSuccesses from tests marked with the expectedFailure() decorator.
+
+ TODO: this should be moved to the "compat" module.
+ """
+ return sys.version_info >= (3, 4) \ No newline at end of file