From c39655725a086b07432995149e43f1884ab1d754 Mon Sep 17 00:00:00 2001 From: Gleb Nikonorov Date: Sat, 27 Jun 2020 19:49:19 -0400 Subject: [PATCH] change if else structure of _warn_bout_missing_assertion --- src/_pytest/config/__init__.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 98c5fd0b4..9ed372959 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -1360,19 +1360,20 @@ class Config: if not _assertion_supported(): from _pytest.warnings import _issue_warning_captured - warning_text = ( - "assertions not in test modules or" - " plugins will be ignored" - " because assert statements are not executed " - "by the underlying Python interpreter " - "(are you using python -O?)\n" - ) if mode == "plain": warning_text = ( "ASSERTIONS ARE NOT EXECUTED" " and FAILING TESTS WILL PASS. Are you" " using python -O?" ) + else: + warning_text = ( + "assertions not in test modules or" + " plugins will be ignored" + " because assert statements are not executed " + "by the underlying Python interpreter " + "(are you using python -O?)\n" + ) _issue_warning_captured( PytestConfigWarning(warning_text), self.hook, stacklevel=2, )