mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Replace catch_warnings with check_warnings when it makes sense. Use assertRaises context manager to simplify some tests.
This commit is contained in:
parent
ad59833649
commit
6257a7bbb2
21 changed files with 112 additions and 226 deletions
|
@ -3,7 +3,6 @@ Test the API of the symtable module.
|
|||
"""
|
||||
import symtable
|
||||
import unittest
|
||||
import warnings
|
||||
|
||||
from test import test_support
|
||||
|
||||
|
@ -44,9 +43,8 @@ def find_block(block, name):
|
|||
|
||||
class SymtableTest(unittest.TestCase):
|
||||
|
||||
with warnings.catch_warnings():
|
||||
# Ignore warnings about "from blank import *"
|
||||
warnings.simplefilter("ignore", SyntaxWarning)
|
||||
with test_support.check_warnings(
|
||||
("import \* only allowed at module level", SyntaxWarning)):
|
||||
top = symtable.symtable(TEST_CODE, "?", "exec")
|
||||
# These correspond to scopes in TEST_CODE
|
||||
Mine = find_block(top, "Mine")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue