change if else structure of _warn_bout_missing_assertion

This commit is contained in:
Gleb Nikonorov 2020-06-27 19:49:19 -04:00
parent 72a39117a8
commit c39655725a
1 changed files with 8 additions and 7 deletions

View File

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