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, )