|
101 | 101 | # threads |
102 | 102 | "threading_setup", "threading_cleanup", "reap_threads", "start_threads", |
103 | 103 | # miscellaneous |
104 | | - "check_warnings", "check_no_resource_warning", "EnvironmentVarGuard", |
| 104 | + "check_warnings", "check_no_resource_warning", "check_no_warnings", |
| 105 | + "EnvironmentVarGuard", |
105 | 106 | "run_with_locale", "swap_item", |
106 | 107 | "swap_attr", "Matcher", "set_memlimit", "SuppressCrashReport", "sortdict", |
107 | 108 | "run_with_tz", "PGO", "missing_compiler_executable", "fd_count", |
@@ -1209,10 +1210,14 @@ def check_warnings(*filters, **kwargs): |
1209 | 1210 |
|
1210 | 1211 |
|
1211 | 1212 | @contextlib.contextmanager |
1212 | | -def check_no_warning(testcase, message='', category=Warning, force_gc=False): |
1213 | | - """Context manager to check that no matching warning is emitted. |
| 1213 | +def check_no_warnings(testcase, message='', category=Warning, force_gc=False): |
| 1214 | + """Context manager to check that no warnings are emitted. |
1214 | 1215 |
|
1215 | | - If force_gc is True, attempt a garbage collection before checking |
| 1216 | + This context manager enables a given warning within its scope |
| 1217 | + and checks that no warnings are emitted even with that warning |
| 1218 | + enabled. |
| 1219 | +
|
| 1220 | + If force_gc is True, a garbage collection is attempted before checking |
1216 | 1221 | for warnings. This may help to catch warnings emitted when objects |
1217 | 1222 | are deleted, such as ResourceWarning. |
1218 | 1223 |
|
@@ -1242,7 +1247,7 @@ def check_no_resource_warning(testcase): |
1242 | 1247 | You must remove the object which may emit ResourceWarning before |
1243 | 1248 | the end of the context manager. |
1244 | 1249 | """ |
1245 | | - with check_no_warning(testcase, category=ResourceWarning, force_gc=True): |
| 1250 | + with check_no_warnings(testcase, category=ResourceWarning, force_gc=True): |
1246 | 1251 | yield |
1247 | 1252 |
|
1248 | 1253 |
|
|
0 commit comments