28
28
# Import with underscores to avoid interfering with user-facing code.
29
29
from matplotlib import set_loglevel as _set_mpl_loglevel
30
30
31
+
31
32
# See https://github.com/matplotlib/matplotlib/issues/23326#issuecomment-1164772708
32
33
_set_mpl_loglevel("critical")
33
34
"""
@@ -73,6 +74,12 @@ def get_notebook_jobs(args: argparse.Namespace) -> Iterator[NotebookJob]:
73
74
)
74
75
continue
75
76
77
+ warning_filter = ""
78
+ if config .check_pending_deprecations :
79
+ warning_filter = "import warnings as _warnings \
80
+ \n _warnings.simplefilter('default', category=PendingDeprecationWarning)"
81
+ pre_execute_code = PRE_EXECUTE_CODE + warning_filter
82
+
76
83
patch = config .get_patch_for_group (group )
77
84
78
85
if patch and not "# nb-tester: allow-write" in patch :
@@ -84,7 +91,7 @@ def get_notebook_jobs(args: argparse.Namespace) -> Iterator[NotebookJob]:
84
91
85
92
yield NotebookJob (
86
93
path = Path (path ),
87
- pre_execute_code = PRE_EXECUTE_CODE ,
94
+ pre_execute_code = pre_execute_code ,
88
95
backend_patch = patch ,
89
96
cell_timeout = config .cell_timeout ,
90
97
write = write ,
@@ -96,6 +103,7 @@ class Config:
96
103
cli_filenames : list [Path ]
97
104
cell_timeout : int
98
105
test_strategy : str
106
+ check_pending_deprecations : bool
99
107
write : bool
100
108
groups : list [dict ]
101
109
@@ -133,6 +141,7 @@ def from_args(cls, args: argparse.Namespace) -> Config:
133
141
cli_filenames = cli_filenames ,
134
142
cell_timeout = args .cell_timeout ,
135
143
test_strategy = "custom" ,
144
+ check_pending_deprecations = args .check_pending_deprecations ,
136
145
write = args .write ,
137
146
groups = groups ,
138
147
)
@@ -150,16 +159,14 @@ def from_args(cls, args: argparse.Namespace) -> Config:
150
159
{"name" : key , ** value } for key , value in config_file ["groups" ].items ()
151
160
]
152
161
test_strategy = args .test_strategy or config_file ["default-strategy" ]
153
- cell_timeout = (
154
- args .cell_timeout or
155
- config_file .get ("test-strategies" , {})
156
- .get (test_strategy , {})
157
- .get ("timeout" , None )
158
- )
162
+ cell_timeout = args .cell_timeout or config_file .get ("test-strategies" , {}).get (
163
+ test_strategy , {}
164
+ ).get ("timeout" , None )
159
165
return cls (
160
166
cli_filenames = args .filenames ,
161
167
cell_timeout = cell_timeout ,
162
168
test_strategy = test_strategy ,
169
+ check_pending_deprecations = args .check_pending_deprecations ,
163
170
write = args .write ,
164
171
groups = groups ,
165
172
)
@@ -261,4 +268,9 @@ def get_parser() -> argparse.ArgumentParser:
261
268
"useful to set if your patch does not use QiskitRuntimeService"
262
269
),
263
270
)
271
+ parser .add_argument (
272
+ "--check-pending-deprecations" ,
273
+ action = "store_true" ,
274
+ help = "Include checking for PendingDeprecationWarnings in notebook outputs" ,
275
+ )
264
276
return parser
0 commit comments