()
| 176 | |
| 177 | |
| 178 | def clear_caches(): |
| 179 | # Clear the warnings registry, so they can be displayed again |
| 180 | for mod in sys.modules.values(): |
| 181 | if hasattr(mod, '__warningregistry__'): |
| 182 | del mod.__warningregistry__ |
| 183 | |
| 184 | # Flush standard output, so that buffered data is sent to the OS and |
| 185 | # associated Python objects are reclaimed. |
| 186 | for stream in (sys.stdout, sys.stderr, sys.__stdout__, sys.__stderr__): |
| 187 | if stream is not None: |
| 188 | stream.flush() |
| 189 | |
| 190 | try: |
| 191 | re = sys.modules['re'] |
| 192 | except KeyError: |
| 193 | pass |
| 194 | else: |
| 195 | re.purge() |
| 196 | |
| 197 | try: |
| 198 | _strptime = sys.modules['_strptime'] |
| 199 | except KeyError: |
| 200 | pass |
| 201 | else: |
| 202 | _strptime._regex_cache.clear() |
| 203 | |
| 204 | try: |
| 205 | urllib_parse = sys.modules['urllib.parse'] |
| 206 | except KeyError: |
| 207 | pass |
| 208 | else: |
| 209 | urllib_parse.clear_cache() |
| 210 | |
| 211 | try: |
| 212 | urllib_request = sys.modules['urllib.request'] |
| 213 | except KeyError: |
| 214 | pass |
| 215 | else: |
| 216 | urllib_request.urlcleanup() |
| 217 | |
| 218 | try: |
| 219 | linecache = sys.modules['linecache'] |
| 220 | except KeyError: |
| 221 | pass |
| 222 | else: |
| 223 | linecache.clearcache() |
| 224 | |
| 225 | try: |
| 226 | mimetypes = sys.modules['mimetypes'] |
| 227 | except KeyError: |
| 228 | pass |
| 229 | else: |
| 230 | mimetypes._default_mime_types() |
| 231 | |
| 232 | try: |
| 233 | filecmp = sys.modules['filecmp'] |
| 234 | except KeyError: |
| 235 | pass |
no test coverage detected
searching dependent graphs…