Merge pull request #5732 from blueyed/drop-py2
assertion.rewrite: use ast.NameConstant(None) directly
This commit is contained in:
commit
67ac878ccf
|
@ -33,6 +33,9 @@ PYTEST_TAG = "{}-pytest-{}".format(sys.implementation.cache_tag, version)
|
||||||
PYC_EXT = ".py" + (__debug__ and "c" or "o")
|
PYC_EXT = ".py" + (__debug__ and "c" or "o")
|
||||||
PYC_TAIL = "." + PYTEST_TAG + PYC_EXT
|
PYC_TAIL = "." + PYTEST_TAG + PYC_EXT
|
||||||
|
|
||||||
|
AST_IS = ast.Is()
|
||||||
|
AST_NONE = ast.NameConstant(None)
|
||||||
|
|
||||||
|
|
||||||
class AssertionRewritingHook:
|
class AssertionRewritingHook:
|
||||||
"""PEP302/PEP451 import hook which rewrites asserts."""
|
"""PEP302/PEP451 import hook which rewrites asserts."""
|
||||||
|
@ -854,10 +857,7 @@ class AssertionRewriter(ast.NodeVisitor):
|
||||||
internally already.
|
internally already.
|
||||||
See issue #3191 for more details.
|
See issue #3191 for more details.
|
||||||
"""
|
"""
|
||||||
|
val_is_none = ast.Compare(node, [AST_IS], [AST_NONE])
|
||||||
# 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])
|
|
||||||
send_warning = ast.parse(
|
send_warning = ast.parse(
|
||||||
"""\
|
"""\
|
||||||
from _pytest.warning_types import PytestAssertRewriteWarning
|
from _pytest.warning_types import PytestAssertRewriteWarning
|
||||||
|
|
Loading…
Reference in New Issue