Skip to content

Commit e4bded8

Browse files
authored
Merge pull request RustPython#1556 from ichyo/ignore-deprecated-warning
Ignore deprecated module warning in a test script
2 parents 194b2cc + 0c12c20 commit e4bded8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/not_impl_gen.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pkgutil
66
import os
77
import sys
8+
import warnings
89

910
sys.path = list(
1011
filter(
@@ -61,10 +62,13 @@ def gen_methods(header, footer, output):
6162
output.write(footer.read())
6263

6364
def get_module_methods(name):
64-
try:
65-
return set(dir(__import__(name))) if name not in ("this", "antigravity") else None
66-
except ModuleNotFoundError:
67-
return None
65+
with warnings.catch_warnings():
66+
# ignore warnings caused by importing deprecated modules
67+
warnings.filterwarnings("ignore", category=DeprecationWarning)
68+
try:
69+
return set(dir(__import__(name))) if name not in ("this", "antigravity") else None
70+
except ModuleNotFoundError:
71+
return None
6872

6973

7074
def gen_modules(header, footer, output):

0 commit comments

Comments
 (0)