Fix tests not to assert a function that already asserts
Maybe there should be a warning about that too?
This commit is contained in:
parent
59a11b6a5d
commit
e0c2ab1901
|
@ -625,8 +625,8 @@ def test_removed_in_pytest4_warning_as_error(testdir, change_default):
|
||||||
result.stdout.fnmatch_lines(["* 1 passed in *"])
|
result.stdout.fnmatch_lines(["* 1 passed in *"])
|
||||||
class TestAssertionWarnings:
|
class TestAssertionWarnings:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def result_warns(result):
|
def assert_result_warns(result):
|
||||||
return result.stdout.fnmatch_lines(["*PytestWarning*"])
|
result.stdout.fnmatch_lines(["*PytestWarning*"])
|
||||||
|
|
||||||
def test_tuple_warning(self, testdir):
|
def test_tuple_warning(self, testdir):
|
||||||
testdir.makepyfile(
|
testdir.makepyfile(
|
||||||
|
@ -636,7 +636,7 @@ class TestAssertionWarnings:
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
result = testdir.runpytest()
|
result = testdir.runpytest()
|
||||||
assert self.result_warns(result)
|
self.assert_result_warns(result)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_file(testdir, return_none):
|
def create_file(testdir, return_none):
|
||||||
|
@ -658,26 +658,25 @@ class TestAssertionWarnings:
|
||||||
def test_none_function_warns(self, testdir):
|
def test_none_function_warns(self, testdir):
|
||||||
self.create_file(testdir, True)
|
self.create_file(testdir, True)
|
||||||
result = testdir.runpytest()
|
result = testdir.runpytest()
|
||||||
assert self.result_warns(result)
|
self.assert_result_warns(result)
|
||||||
|
|
||||||
|
@pytest.mark.xfail(strict=True)
|
||||||
def test_assert_is_none_no_warn(self, testdir):
|
def test_assert_is_none_no_warn(self, testdir):
|
||||||
"""Tests a more simple case of `test_none_function_warns` where `assert None` is explicitly called"""
|
"""Tests a more simple case of `test_none_function_warns` where `assert None` is explicitly called"""
|
||||||
testdir.makepyfile(
|
testdir.makepyfile(
|
||||||
"""
|
"""
|
||||||
def foo(return_none):
|
def foo():
|
||||||
if return_none:
|
return None
|
||||||
return None
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def test_foo():
|
def test_foo():
|
||||||
assert foo(True) is None
|
assert foo() is None
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
result = testdir.runpytest()
|
result = testdir.runpytest()
|
||||||
assert not self.result_warns(result)
|
self.assert_result_warns(result)
|
||||||
|
|
||||||
|
@pytest.mark.xfail(strict=True)
|
||||||
def test_false_function_no_warn(self, testdir):
|
def test_false_function_no_warn(self, testdir):
|
||||||
self.create_file(testdir, False)
|
self.create_file(testdir, False)
|
||||||
result = testdir.runpytest()
|
result = testdir.runpytest()
|
||||||
assert not self.result_warns(result)
|
self.assert_result_warns(result)
|
||||||
|
|
Loading…
Reference in New Issue