berkerpeksag / astor

Python AST read/write
https://pypi.org/project/astor/
BSD 3-Clause "New" or "Revised" License
810 stars 102 forks source link

add support for Python 3.5 infix matrix multiplication #17

Closed zackmdavis closed 9 years ago

zackmdavis commented 9 years ago

This came up while working on a momentarily forthcoming pull request (the topic of which can be easily inferred) for Hy.

zackmdavis commented 9 years ago

CI informs me that this project is supposed to be Python 2.6–compatible, where the @unittest.skipIf decorator I had tried to use doesn't exist. Fixed-up and force-pushed.

berkerpeksag commented 9 years ago

Could you also add a test to test_codegen.py?

zackmdavis commented 9 years ago

Hm. f27c059 uses unittest2 if available (and also adds a test to test_codegen), but CI fails again on Python 2.6 ('module' object has no attribute 'skipIf').

berkerpeksag commented 9 years ago

There's a typo in the import statement :)

import unitttest2 as unittest

See three t in unittest2.

zackmdavis commented 9 years ago

(force-pushed) Okay, what about 30b310d? In addition to using the correct number of ts in "unittest2", it explicitly checks for for SkipTest, and avoids the context-manager form of assertRaises, so it should work on Python 2.6 regardless.

berkerpeksag commented 9 years ago

Thanks! The test looks good. We can simply the other test a bit:

@unittest.skipUnless(sys.version_info >= (3, 5), "ast.MatMult introduced in Python 3.5")
def test_get_mat_mult(self):
    self.assertEqual('@', astor.misc.get_binop(ast.MatMult()))
zackmdavis commented 9 years ago

(amended again)

berkerpeksag commented 9 years ago

Thanks! :) I will release 0.5 today or tomorrow.

berkerpeksag commented 9 years ago

Done: https://pypi.python.org/pypi/astor