Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
86bbe95b
Commit
86bbe95b
authored
Nov 11, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Plain Diff
Issue #23839: Various caches now are cleared before running every test file.
parents
624dd1d1
fbdd9aaf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
26 deletions
+91
-26
Lib/test/libregrtest/refleak.py
Lib/test/libregrtest/refleak.py
+84
-25
Lib/test/libregrtest/runtest.py
Lib/test/libregrtest/runtest.py
+2
-1
Misc/NEWS
Misc/NEWS
+5
-0
No files found.
Lib/test/libregrtest/refleak.py
View file @
86bbe95b
...
...
@@ -122,17 +122,9 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
def
dash_R_cleanup
(
fs
,
ps
,
pic
,
zdc
,
abcs
):
import
gc
,
copyreg
import
_strptime
,
linecache
import
urllib.parse
,
urllib
.
request
,
mimetypes
,
doctest
import
struct
,
filecmp
,
collections
.
abc
from
distutils.dir_util
import
_path_created
import
collections.abc
from
weakref
import
WeakSet
# Clear the warnings registry, so they can be displayed again
for
mod
in
sys
.
modules
.
values
():
if
hasattr
(
mod
,
'__warningregistry__'
):
del
mod
.
__warningregistry__
# Restore some original values.
warnings
.
filters
[:]
=
fs
copyreg
.
dispatch_table
.
clear
()
...
...
@@ -159,6 +151,23 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
obj
.
_abc_cache
.
clear
()
obj
.
_abc_negative_cache
.
clear
()
clear_caches
()
# Collect cyclic trash and read memory statistics immediately after.
func1
=
sys
.
getallocatedblocks
func2
=
sys
.
gettotalrefcount
gc
.
collect
()
return
func1
(),
func2
(),
fd_count
()
def
clear_caches
():
import
gc
# Clear the warnings registry, so they can be displayed again
for
mod
in
sys
.
modules
.
values
():
if
hasattr
(
mod
,
'__warningregistry__'
):
del
mod
.
__warningregistry__
# Flush standard output, so that buffered data is sent to the OS and
# associated Python objects are reclaimed.
for
stream
in
(
sys
.
stdout
,
sys
.
stderr
,
sys
.
__stdout__
,
sys
.
__stderr__
):
...
...
@@ -166,20 +175,74 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
stream
.
flush
()
# Clear assorted module caches.
_path_created
.
clear
()
# Don't worry about resetting the cache if the module is not loaded
try
:
distutils_dir_util
=
sys
.
modules
[
'distutils.dir_util'
]
except
KeyError
:
pass
else
:
distutils_dir_util
.
_path_created
.
clear
()
re
.
purge
()
_strptime
.
_regex_cache
.
clear
()
urllib
.
parse
.
clear_cache
()
urllib
.
request
.
urlcleanup
()
linecache
.
clearcache
()
mimetypes
.
_default_mime_types
()
filecmp
.
_cache
.
clear
()
struct
.
_clearcache
()
doctest
.
master
=
None
try
:
import
ctypes
except
ImportError
:
# Don't worry about resetting the cache if ctypes is not supported
_strptime
=
sys
.
modules
[
'_strptime'
]
except
KeyError
:
pass
else
:
_strptime
.
_regex_cache
.
clear
()
try
:
urllib_parse
=
sys
.
modules
[
'urllib.parse'
]
except
KeyError
:
pass
else
:
urllib_parse
.
clear_cache
()
try
:
urllib_request
=
sys
.
modules
[
'urllib.request'
]
except
KeyError
:
pass
else
:
urllib_request
.
urlcleanup
()
try
:
linecache
=
sys
.
modules
[
'linecache'
]
except
KeyError
:
pass
else
:
linecache
.
clearcache
()
try
:
mimetypes
=
sys
.
modules
[
'mimetypes'
]
except
KeyError
:
pass
else
:
mimetypes
.
_default_mime_types
()
try
:
filecmp
=
sys
.
modules
[
'filecmp'
]
except
KeyError
:
pass
else
:
filecmp
.
_cache
.
clear
()
try
:
struct
=
sys
.
modules
[
'struct'
]
except
KeyError
:
pass
else
:
struct
.
_clearcache
()
try
:
doctest
=
sys
.
modules
[
'doctest'
]
except
KeyError
:
pass
else
:
doctest
.
master
=
None
try
:
ctypes
=
sys
.
modules
[
'ctypes'
]
except
KeyError
:
pass
else
:
ctypes
.
_reset_cache
()
...
...
@@ -192,11 +255,7 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
for
f
in
typing
.
_cleanups
:
f
()
# Collect cyclic trash and read memory statistics immediately after.
func1
=
sys
.
getallocatedblocks
func2
=
sys
.
gettotalrefcount
gc
.
collect
()
return
func1
(),
func2
(),
fd_count
()
def
warm_caches
():
...
...
Lib/test/libregrtest/runtest.py
View file @
86bbe95b
...
...
@@ -7,7 +7,7 @@ import time
import
traceback
import
unittest
from
test
import
support
from
test.libregrtest.refleak
import
dash_R
from
test.libregrtest.refleak
import
dash_R
,
clear_caches
from
test.libregrtest.save_env
import
saved_test_environment
...
...
@@ -146,6 +146,7 @@ def runtest_inner(ns, test, display_failure=True):
else
:
# Always import it from the test package
abstest
=
'test.'
+
test
clear_caches
()
with
saved_test_environment
(
test
,
ns
.
verbose
,
ns
.
quiet
,
pgo
=
ns
.
pgo
)
as
environment
:
start_time
=
time
.
time
()
the_module
=
importlib
.
import_module
(
abstest
)
...
...
Misc/NEWS
View file @
86bbe95b
...
...
@@ -55,6 +55,11 @@ Documentation
-
Issue
#
28513
:
Documented
command
-
line
interface
of
zipfile
.
Tests
-----
-
Issue
#
23839
:
Various
caches
now
are
cleared
before
running
every
test
file
.
What
's New in Python 3.6.0 beta 3
=================================
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment