Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1290: Py3.5's @ operator/assertion rewriting. #1361

Merged
merged 1 commit into from
Feb 6, 2016

Conversation

tomviner
Copy link
Contributor

@tomviner tomviner commented Feb 5, 2016

Fix for #1290

Support ast.MatMult when it's present. And add a test that runs on Python 3.5+. See PEP 465 -- A dedicated infix operator for matrix multiplication

@pytest.mark.skipif("sys.version_info < (3,5)")
def test_at_operator_issue1290(self):
def f():
class Matrix:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you will have to use eval or exec here to avoid syntax errors in Python versions < 3.5. 😁

@nicoddemus
Copy link
Member

Thanks a lot @tomviner! 😄

@tomviner tomviner force-pushed the issue1290-at-operator branch from 35d6bbf to 552cfa7 Compare February 5, 2016 22:51
@tomviner
Copy link
Contributor Author

tomviner commented Feb 5, 2016

@nicoddemus I've had another go with testdir.makepyfile

@tomviner tomviner force-pushed the issue1290-at-operator branch from 552cfa7 to f63b706 Compare February 5, 2016 22:54

def test_multmat_operator():
assert Matrix(2) @ Matrix(3) == 42""")
testdir.runpytest().assert_outcomes(failed=1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm doesn't this test also pass if you take out your fix in rewrite.py? Wouldn't be better to make the the inner test pass?

@tomviner tomviner force-pushed the issue1290-at-operator branch from f63b706 to 7d10701 Compare February 5, 2016 23:10
@tomviner
Copy link
Contributor Author

tomviner commented Feb 5, 2016

@nicoddemus good point, I got confused in thinking that a failing inner test was required to engage the rewrite code, but that's obviously not true as shown in @Shinkenjoe's original test case. Changed.

@nicoddemus
Copy link
Member

Excellent, thanks! 😄

@nicoddemus nicoddemus merged commit 7d10701 into pytest-dev:master Feb 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants