You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
More 2-x grammar test fixes
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
|
from xdis.version_info import IS_PYPY, PYTHON_VERSION_TRIPLE
|
||||||
|
|
||||||
from uncompyle6.parser import get_python_parser, python_parser
|
from uncompyle6.parser import get_python_parser, python_parser
|
||||||
from uncompyle6.scanner import get_scanner
|
from uncompyle6.scanner import get_scanner
|
||||||
from xdis.version_info import PYTHON_VERSION_TRIPLE, IS_PYPY
|
|
||||||
|
|
||||||
|
|
||||||
def test_grammar():
|
def test_grammar():
|
||||||
@@ -28,7 +30,7 @@ def test_grammar():
|
|||||||
|
|
||||||
expect_lhs.add("get_iter")
|
expect_lhs.add("get_iter")
|
||||||
|
|
||||||
if PYTHON_VERSION_TRIPLE >= (3, 8) or PYTHON_VERSION_TRIPLE < (3, 0):
|
if PYTHON_VERSION_TRIPLE >= (3, 8):
|
||||||
expect_lhs.add("stmts_opt")
|
expect_lhs.add("stmts_opt")
|
||||||
else:
|
else:
|
||||||
expect_lhs.add("async_with_as_stmt")
|
expect_lhs.add("async_with_as_stmt")
|
||||||
@@ -46,7 +48,10 @@ def test_grammar():
|
|||||||
expect_lhs.add("kv3")
|
expect_lhs.add("kv3")
|
||||||
unused_rhs.add("dict")
|
unused_rhs.add("dict")
|
||||||
else:
|
else:
|
||||||
if PYTHON_VERSION_TRIPLE < (3, 7) and PYTHON_VERSION_TRIPLE[:2] not in ((2, 7), (2, 6)):
|
if PYTHON_VERSION_TRIPLE < (3, 7) and PYTHON_VERSION_TRIPLE[:2] not in (
|
||||||
|
(2, 7),
|
||||||
|
(2, 6),
|
||||||
|
):
|
||||||
# NOTE: this may disappear
|
# NOTE: this may disappear
|
||||||
expect_lhs.add("except_handler_else")
|
expect_lhs.add("except_handler_else")
|
||||||
|
|
||||||
@@ -101,7 +106,9 @@ def test_grammar():
|
|||||||
)
|
)
|
||||||
reduced_dup_rhs = dict((k, dup_rhs[k]) for k in dup_rhs if k not in expect_dup_rhs)
|
reduced_dup_rhs = dict((k, dup_rhs[k]) for k in dup_rhs if k not in expect_dup_rhs)
|
||||||
if reduced_dup_rhs:
|
if reduced_dup_rhs:
|
||||||
print("\nPossible duplicate RHS that might be folded, into one of the LHS symbols")
|
print(
|
||||||
|
"\nPossible duplicate RHS that might be folded, into one of the LHS symbols"
|
||||||
|
)
|
||||||
for k in reduced_dup_rhs:
|
for k in reduced_dup_rhs:
|
||||||
print(k, reduced_dup_rhs[k])
|
print(k, reduced_dup_rhs[k])
|
||||||
# assert not reduced_dup_rhs, reduced_dup_rhs
|
# assert not reduced_dup_rhs, reduced_dup_rhs
|
||||||
|
@@ -29,6 +29,9 @@ class TestGrammar(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
expect_lhs.add("kwarg")
|
expect_lhs.add("kwarg")
|
||||||
|
|
||||||
|
if PYTHON_VERSION_TRIPLE[:2] <= (3, 6):
|
||||||
|
unused_rhs.add("call")
|
||||||
|
|
||||||
if PYTHON_VERSION_TRIPLE[:2] == (2, 7):
|
if PYTHON_VERSION_TRIPLE[:2] == (2, 7):
|
||||||
expect_lhs.add("kv3")
|
expect_lhs.add("kv3")
|
||||||
expect_lhs.add("kvlist")
|
expect_lhs.add("kvlist")
|
||||||
|
Reference in New Issue
Block a user