Closed
Description
Hi there,
It seems like the @ operator isn't recognized by something int the assertion_rewrite procedure.
With --assert=plain there is no problem.
I did some fake test to single out the problem in fake_matrix.py:
class FakeMatrix:
def __init__(self, num):
self.num = num
def __matmul__(self, other):
return self.num * other.num
and the test file:
from fake_matrix import FakeMatrix
def test_multmat_operator():
assert FakeMatrix(2) @ FakeMatrix(3) == 6
traceback:
platform linux -- Python 3.5.0+, pytest-2.8.5, py-1.4.31, pluggy-0.3.1 -- /home/snail/.virtualenvs/fip/bin/python3.5
cachedir: .cache
rootdir: /home/snail/comp/python/fluent/pytest_bug_report, inifile:
collected 0 items / 1 errors
================================================================= ERRORS =================================================================
____________________________________________________ ERROR collecting test_multmat.py ____________________________________________________
/home/snail/.virtualenvs/fip/lib/python3.5/site-packages/py/_path/local.py:650: in pyimport
__import__(modname)
<frozen importlib._bootstrap>:969: in _find_and_load
???
<frozen importlib._bootstrap>:954: in _find_and_load_unlocked
???
<frozen importlib._bootstrap>:892: in _find_spec
???
<frozen importlib._bootstrap>:873: in _find_spec_legacy
???
/home/snail/.virtualenvs/fip/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:143: in find_module
source_stat, co = _rewrite_test(state, fn_pypath)
/home/snail/.virtualenvs/fip/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:290: in _rewrite_test
rewrite_asserts(tree)
/home/snail/.virtualenvs/fip/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:348: in rewrite_asserts
AssertionRewriter().run(mod)
/home/snail/.virtualenvs/fip/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:569: in run
new.extend(self.visit(child))
/usr/lib/python3.5/ast.py:245: in visit
return visitor(node)
/home/snail/.virtualenvs/fip/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:677: in visit_Assert
top_condition, explanation = self.visit(assert_.test)
/usr/lib/python3.5/ast.py:245: in visit
return visitor(node)
/home/snail/.virtualenvs/fip/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:852: in visit_Compare
left_res, left_expl = self.visit(comp.left)
/usr/lib/python3.5/ast.py:245: in visit
return visitor(node)
/home/snail/.virtualenvs/fip/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:761: in visit_BinOp
symbol = binop_map[binop.op.__class__]
E KeyError: <class '_ast.MatMult'>
My system is debian linux stretch, and as you can see I'm using Python 3.5.0+, pytest-2.8.5 on a virtualenv
Metadata
Metadata
Assignees
Labels
grave problem or usability issue that affects lots of usersdevelopers would like help from experts on this topicmight present some backward compatibility issues which should be carefully noted in the changelogproblem that needs to be addressednew feature or API change, should be merged into features branch