Skip to content

Commit 97d028e

Browse files
committed
Add more tests
1 parent c15635b commit 97d028e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Lib/test/test_compile.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,24 @@ async def name_4():
16361636
pass
16371637
[[]]
16381638

1639+
def test_compile_warnings(self):
1640+
# See gh-131927
1641+
# Compile warnings originating from the same file and
1642+
# line are now only emitted once.
1643+
with warnings.catch_warnings(record=True) as caught:
1644+
warnings.simplefilter("default")
1645+
compile('1 is 1', '<stdin>', 'eval')
1646+
compile('1 is 1', '<stdin>', 'eval')
1647+
1648+
self.assertEqual(len(caught), 1)
1649+
1650+
with warnings.catch_warnings(record=True) as caught:
1651+
warnings.simplefilter("always")
1652+
compile('1 is 1', '<stdin>', 'eval')
1653+
compile('1 is 1', '<stdin>', 'eval')
1654+
1655+
self.assertEqual(len(caught), 2)
1656+
16391657
class TestBooleanExpression(unittest.TestCase):
16401658
class Value:
16411659
def __init__(self):

0 commit comments

Comments
 (0)