Merge branch 'issue1290-at-operator'
This commit is contained in:
commit
c6938221ab
|
@ -57,11 +57,15 @@
|
||||||
``Config.fromdictargs`` now represents its input much more faithfully.
|
``Config.fromdictargs`` now represents its input much more faithfully.
|
||||||
Thanks to `@bukzor`_ for the complete PR (`#680`_).
|
Thanks to `@bukzor`_ for the complete PR (`#680`_).
|
||||||
|
|
||||||
|
* Fix (`#1290`_): support Python 3.5's `@` operator in assertion rewriting.
|
||||||
|
Thanks `@Shinkenjoe`_ for report with test case and `@tomviner`_ for the PR.
|
||||||
|
|
||||||
|
|
||||||
.. _#1040: https://github.com/pytest-dev/pytest/pull/1040
|
.. _#1040: https://github.com/pytest-dev/pytest/pull/1040
|
||||||
.. _#680: https://github.com/pytest-dev/pytest/issues/680
|
.. _#680: https://github.com/pytest-dev/pytest/issues/680
|
||||||
.. _#1287: https://github.com/pytest-dev/pytest/pull/1287
|
.. _#1287: https://github.com/pytest-dev/pytest/pull/1287
|
||||||
.. _#1226: https://github.com/pytest-dev/pytest/pull/1226
|
.. _#1226: https://github.com/pytest-dev/pytest/pull/1226
|
||||||
|
.. _#1290: https://github.com/pytest-dev/pytest/pull/1290
|
||||||
.. _@MichaelAquilina: https://github.com/MichaelAquilina
|
.. _@MichaelAquilina: https://github.com/MichaelAquilina
|
||||||
.. _@bukzor: https://github.com/bukzor
|
.. _@bukzor: https://github.com/bukzor
|
||||||
.. _@nicoddemus: https://github.com/nicoddemus
|
.. _@nicoddemus: https://github.com/nicoddemus
|
||||||
|
@ -69,7 +73,8 @@
|
||||||
.. _@codewarrior0: https://github.com/codewarrior0
|
.. _@codewarrior0: https://github.com/codewarrior0
|
||||||
.. _@jaraco: https://github.com/jaraco
|
.. _@jaraco: https://github.com/jaraco
|
||||||
.. _@The-Compiler: https://github.com/The-Compiler
|
.. _@The-Compiler: https://github.com/The-Compiler
|
||||||
|
.. _@Shinkenjoe: https://github.com/Shinkenjoe
|
||||||
|
.. _@tomviner: https://github.com/tomviner
|
||||||
|
|
||||||
|
|
||||||
2.8.7
|
2.8.7
|
||||||
|
|
|
@ -453,6 +453,11 @@ binop_map = {
|
||||||
ast.In: "in",
|
ast.In: "in",
|
||||||
ast.NotIn: "not in"
|
ast.NotIn: "not in"
|
||||||
}
|
}
|
||||||
|
# Python 3.5+ compatibility
|
||||||
|
try:
|
||||||
|
binop_map[ast.MatMult] = "@"
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
|
||||||
# Python 3.4+ compatibility
|
# Python 3.4+ compatibility
|
||||||
if hasattr(ast, "NameConstant"):
|
if hasattr(ast, "NameConstant"):
|
||||||
|
|
|
@ -280,6 +280,19 @@ class TestAssertionRewrite:
|
||||||
assert False or 4 % 2
|
assert False or 4 % 2
|
||||||
assert getmsg(f) == "assert (False or (4 % 2))"
|
assert getmsg(f) == "assert (False or (4 % 2))"
|
||||||
|
|
||||||
|
@pytest.mark.skipif("sys.version_info < (3,5)")
|
||||||
|
def test_at_operator_issue1290(self, testdir):
|
||||||
|
testdir.makepyfile("""
|
||||||
|
class Matrix:
|
||||||
|
def __init__(self, num):
|
||||||
|
self.num = num
|
||||||
|
def __matmul__(self, other):
|
||||||
|
return self.num * other.num
|
||||||
|
|
||||||
|
def test_multmat_operator():
|
||||||
|
assert Matrix(2) @ Matrix(3) == 6""")
|
||||||
|
testdir.runpytest().assert_outcomes(passed=1)
|
||||||
|
|
||||||
def test_call(self):
|
def test_call(self):
|
||||||
def g(a=42, *args, **kwargs):
|
def g(a=42, *args, **kwargs):
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in New Issue