Skip to content

Commit 3f02bff

Browse files
committed
fix
1 parent b9f3342 commit 3f02bff

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/test_folding.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,16 +337,36 @@ def test_not_false_in_conditional():
337337
"""
338338
Test that 'not False' is folded to 'True' in a conditional.
339339
"""
340+
if sys.version_info < (3, 4):
341+
pytest.skip('NameConstant not in python < 3.4')
342+
340343
run_test('if not False:pass', 'if True:pass')
341344

342345

343346
def test_not_not_true_in_assignment():
344347
"""
345348
Test that 'not not True' is folded to 'True' in an assignment.
346349
"""
350+
if sys.version_info < (3, 4):
351+
pytest.skip('NameConstant not in python < 3.4')
352+
347353
run_test('x=not not True', 'x=True')
348354

349355

356+
def test_bool_not_folded_before_34():
357+
"""
358+
Test that boolean 'not' expressions are not folded in Python < 3.4.
359+
360+
NameConstant was introduced in Python 3.4, so we cannot fold boolean
361+
constants in earlier versions.
362+
"""
363+
if sys.version_info >= (3, 4):
364+
pytest.skip('Only applies to python < 3.4')
365+
366+
run_test('if not False:pass', 'if not False:pass')
367+
run_test('x=not not True', 'x=not not True')
368+
369+
350370
def test_constant_folding_enabled_by_default():
351371
"""Verify constant folding is enabled by default."""
352372
source = 'x = 10 + 10'

0 commit comments

Comments
 (0)