Closed itraviv closed 4 years ago
Good job. Before I do a thorough code review, please take care of these issues:
I see that you closed your PR, maybe you're opening another one or something, I'll stay tuned.
i closed it because it failed the CI. i will fix and organize the commits as you requested. stay tuned for an improved version.
Cool. You could keep it open if you want though and keep updating it until
the CI passes, it's all good. You can also run tests locally with pytest, I
think that just running pytest
will do the trick.
On Tue, Nov 19, 2019 at 1:58 PM itraviv notifications@github.com wrote:
i closed it because it failed the CI. i will fix and organize the commits as you requested. stay tuned for an improved version.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cool-RR/PySnooper/pull/169?email_source=notifications&email_token=AAAN3SW57IBMIDHNXGTLZVTQUPIHHA5CNFSM4JPB55D2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEN6KDI#issuecomment-555476237, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAN3SQBBDXIZRUOMTYK5BDQUPIHHANCNFSM4JPB55DQ .
yea, pytest is not the issue here (i have also added tests and made sure everything passes), it's the python2.7 compatibility that fails. as for the regex - i couldn't find a better way since the number of figures appearing in the memory address (after the 0x..) is very platform and context specific (memory address range). if you have any other suggestion - please share with me.
Hmm, I think it's possible to figure out whether the default repr is used, here's some inspiration under Python 3, you could probably do something similar in Python 2:
In [15]: class A:
...: pass
...:
In [16]: class B(A):
...: def __repr__(self): return 'foo'
...:
In [17]: a.__repr__
Out[17]: <method-wrapper '__repr__' of A object at 0x0000000004D0D748>
In [18]: a.__repr__.__objclass__
Out[18]: object
In [19]: b.__repr__
Out[19]: <bound method B.__repr__ of foo>
In [20]: b.__repr__.__func__
Out[20]: <function __main__.B.__repr__(self)>
In [21]: b.__repr__.__func__.__qualname__
Out[21]: 'B.__repr__'
Another thought though: Maybe there are non-default reprs which also use the memory address. I actually think your regex method might be superior, so let's go with that. I'm keeping my above code here for reference in case we'll want it later.
opened new PR with all mentioned changes: https://github.com/cool-RR/PySnooper/pull/170
normalizing output - removing machine specific data:
basename
of the path.tests:
normalize=True
andnormalize=False
to preserve compatability.assert_output
can now verify the output of a normalized trace.