Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/_pytest/assertion/rewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
PYC_EXT = ".py" + (__debug__ and "c" or "o")
PYC_TAIL = "." + PYTEST_TAG + PYC_EXT

AST_IS = ast.Is()
AST_NONE = ast.NameConstant(None)


class AssertionRewritingHook:
"""PEP302/PEP451 import hook which rewrites asserts."""
Expand Down Expand Up @@ -854,10 +857,7 @@ def warn_about_none_ast(self, node, module_path, lineno):
internally already.
See issue #3191 for more details.
"""

# Using parse because it is different between py2 and py3.
AST_NONE = ast.parse("None").body[0].value
val_is_none = ast.Compare(node, [ast.Is()], [AST_NONE])
val_is_none = ast.Compare(node, [AST_IS], [AST_NONE])
send_warning = ast.parse(
"""\
from _pytest.warning_types import PytestAssertRewriteWarning
Expand Down