diff --git a/test/test_hoist_literals.py b/test/test_hoist_literals.py index 39e15d13..4490882f 100644 --- a/test/test_hoist_literals.py +++ b/test/test_hoist_literals.py @@ -494,6 +494,9 @@ def test_hoisted_types_py2(): compare_ast(expected_ast, actual_ast) def test_no_hoist_slots(): + if sys.version_info < (3, 3): + pytest.skip('Literal rename iterates bindings in a different order with Python2') + source = ''' class SlotsA(object): __slots__ = ['aaaaa', 'bbbbb'] @@ -515,6 +518,35 @@ class SlotsB(object): expected_ast = ast.parse(expected) actual_ast = hoist(source) + print(print_ast(expected_ast)) + print(print_ast(actual_ast)) + compare_ast(expected_ast, actual_ast) + +def test_no_hoist_slots_python2(): + if sys.version_info > (2, 7): + pytest.skip('Literal rename iterates bindings in a different order with Python3') + + source = ''' +class SlotsA(object): + __slots__ = ['aaaaa', 'bbbbb'] + notslots = ['aaaaa', 'bbbbb'] +class SlotsB(object): + __slots__ = 'aaaaa', 'bbbbb' + notslots = ['aaaaa', 'bbbbb'] +''' + expected = ''' +B = 'aaaaa' +A = 'bbbbb' +class SlotsA(object): + __slots__ = ['aaaaa', 'bbbbb'] + notslots = [A, B] +class SlotsB(object): + __slots__ = 'aaaaa', 'bbbbb' + notslots = [A, B] +''' + expected_ast = ast.parse(expected) + actual_ast = hoist(source) + print(print_ast(expected_ast)) print(print_ast(actual_ast)) compare_ast(expected_ast, actual_ast) \ No newline at end of file