2019-06-11 18:08:50 +00:00
|
|
|
from uncompyle6 import PYTHON_VERSION
|
2018-03-01 03:05:12 +00:00
|
|
|
from uncompyle6.scanners.tok import Token
|
|
|
|
|
2020-01-22 09:49:44 +00:00
|
|
|
|
2018-03-01 03:05:12 +00:00
|
|
|
def test_token():
|
|
|
|
# Test token formatting of: LOAD_CONST None
|
2020-01-22 09:49:44 +00:00
|
|
|
t = Token("LOAD_CONST", offset=0, attr=None, pattr=None, has_arg=True)
|
2020-03-31 14:12:52 +00:00
|
|
|
expect = " 0 LOAD_CONST None"
|
2018-03-01 03:05:12 +00:00
|
|
|
# print(t.format())
|
|
|
|
assert t
|
|
|
|
assert t.format() == expect
|
|
|
|
|
|
|
|
# Make sure equality testing of tokens ignores offset
|
2020-01-22 09:49:44 +00:00
|
|
|
t2 = Token("LOAD_CONST", offset=2, attr=None, pattr=None, has_arg=True)
|
2018-03-01 03:05:12 +00:00
|
|
|
assert t2 == t
|
|
|
|
|
|
|
|
# Make sure formatting of: LOAD_CONST False. We assume False is the 0th index
|
|
|
|
# of co_consts.
|
2020-01-22 09:49:44 +00:00
|
|
|
t = Token("LOAD_CONST", offset=1, attr=False, pattr=False, has_arg=True)
|
2020-03-31 14:12:52 +00:00
|
|
|
expect = " 1 LOAD_CONST False"
|
2018-03-01 03:05:12 +00:00
|
|
|
assert t.format() == expect
|
2018-03-01 22:23:58 +00:00
|
|
|
|
2020-01-22 09:49:44 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2018-03-01 22:23:58 +00:00
|
|
|
test_token()
|