berkerpeksag / astor

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

Deprecate old API (issue #59) #66

Closed pmaupin closed 7 years ago

pmaupin commented 7 years ago

DeprecationWarnings don't appear by default, so I used FutureWarning to insure it shows up.

If this is wrong, we can change.

berkerpeksag commented 7 years ago

We also need to test the actual deprecation warnings. For example:

with self.assertWarns(DeprecationWarning):
    astor.parsefile(__file__)
pmaupin commented 7 years ago

I wasn't sure how to do that; that's why I made something noisy enough to show up :)

I'll look into the stack level and push a fix.

pmaupin commented 7 years ago

Turns out the proper stack level is 2 in both cases. And for some reason, my 2.7 test runners don't have assertWarns. Guess I need unittest2? Edited: Yeah, that was it.

berkerpeksag commented 7 years ago

Oops, sorry I forgot it wasn't added in Python 2.7 :(