From 1654b77ca0febbe047a56cdce59e14755064b3e6 Mon Sep 17 00:00:00 2001 From: Tomer Keren Date: Sun, 14 Oct 2018 19:13:00 +0300 Subject: [PATCH] [#3191] Set up tests to confirm warnings --- testing/test_warnings.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/testing/test_warnings.py b/testing/test_warnings.py index 53d9c71cd..9dbe7f0d6 100644 --- a/testing/test_warnings.py +++ b/testing/test_warnings.py @@ -623,3 +623,38 @@ def test_removed_in_pytest4_warning_as_error(testdir, change_default): else: assert change_default in ("ini", "cmdline") result.stdout.fnmatch_lines(["* 1 passed in *"]) +class TestAssertionWarnings: + def test_tuple_warning(self, testdir): + testdir.makepyfile( + """ + def test_foo(): + assert (1,2) + """ + ) + with pytest.warns(pytest.PytestWarning): + testdir.runpytest_subprocess() + + def create_file(self, testdir, return_none): + testdir.makepyfile( + """ + def foo(return_none): + if return_none: + return None + else: + return False + + def test_foo(): + assert foo({return_none}) + """.format( + return_none=return_none + ) + ) + + def test_none_function_warns(self, testdir): + self.create_file(testdir, True) + with pytest.warns(pytest.PytestWarning): + testdir.runpytest_subprocess() + + def test_false_function_no_warn(self, testdir): + self.create_file(testdir, False) + testdir.runpytest_subprocess("-W error:PytestWarning")