You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
We were not showing the proper value for None, or False. Start a unit test for Token(). I think this cleans the Token class up a little more. More work is needed for MAKE_FUNCTION... Note: Some debug stuff is commented out in make_funciton.py for upcoming work.
21 lines
739 B
Python
21 lines
739 B
Python
from uncompyle6.scanners.tok import Token
|
|
|
|
def test_token():
|
|
# Test token formatting of: LOAD_CONST None
|
|
t = Token('LOAD_CONST', offset=0, attr=None, pattr=None, has_arg=True)
|
|
expect = ' 0 LOAD_CONST None'
|
|
# print(t.format())
|
|
assert t
|
|
assert t.format() == expect
|
|
|
|
# Make sure equality testing of tokens ignores offset
|
|
t2 = Token('LOAD_CONST', offset=2, attr=None, pattr=None, has_arg=True)
|
|
assert t2 == t
|
|
|
|
|
|
# Make sure formatting of: LOAD_CONST False. We assume False is the 0th index
|
|
# of co_consts.
|
|
t = Token('LOAD_CONST', offset=1, attr=False, pattr=False, has_arg=True)
|
|
expect = ' 1 LOAD_CONST 0 False'
|
|
assert t.format() == expect
|