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
a793037d
Commit
a793037d
authored
Jul 03, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #19527: Fixed tests with defined COUNT_ALLOCS.
parent
af65872d
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
26 additions
and
6 deletions
+26
-6
Lib/test/support/__init__.py
Lib/test/support/__init__.py
+3
-0
Lib/test/test_gc.py
Lib/test/test_gc.py
+5
-2
Lib/test/test_io.py
Lib/test/test_io.py
+2
-0
Lib/test/test_logging.py
Lib/test/test_logging.py
+1
-0
Lib/test/test_module.py
Lib/test/test_module.py
+3
-1
Lib/test/test_sys.py
Lib/test/test_sys.py
+6
-2
Lib/test/test_threading.py
Lib/test/test_threading.py
+3
-1
Lib/test/test_traceback.py
Lib/test/test_traceback.py
+1
-0
Lib/test/test_warnings/__init__.py
Lib/test/test_warnings/__init__.py
+1
-0
Lib/test/test_weakref.py
Lib/test/test_weakref.py
+1
-0
No files found.
Lib/test/support/__init__.py
View file @
a793037d
...
@@ -2069,6 +2069,9 @@ def strip_python_stderr(stderr):
...
@@ -2069,6 +2069,9 @@ def strip_python_stderr(stderr):
stderr
=
re
.
sub
(
br"\
[
\d+ refs, \
d+
blocks\
]
\r?\n?"
,
b""
,
stderr
).
strip
()
stderr
=
re
.
sub
(
br"\
[
\d+ refs, \
d+
blocks\
]
\r?\n?"
,
b""
,
stderr
).
strip
()
return
stderr
return
stderr
requires_type_collecting
=
unittest
.
skipIf
(
hasattr
(
sys
,
'getcounts'
),
'types are immortal if COUNT_ALLOCS is defined'
)
def
args_from_interpreter_flags
():
def
args_from_interpreter_flags
():
"""Return a list of command-line arguments reproducing the current
"""Return a list of command-line arguments reproducing the current
settings in sys.flags and sys.warnoptions."""
settings in sys.flags and sys.warnoptions."""
...
...
Lib/test/test_gc.py
View file @
a793037d
import
unittest
import
unittest
from
test.support
import
(
verbose
,
refcount_test
,
run_unittest
,
from
test.support
import
(
verbose
,
refcount_test
,
run_unittest
,
strip_python_stderr
,
cpython_only
,
start_threads
,
strip_python_stderr
,
cpython_only
,
start_threads
,
temp_dir
)
temp_dir
,
requires_type_collecting
)
from
test.support.script_helper
import
assert_python_ok
,
make_script
from
test.support.script_helper
import
assert_python_ok
,
make_script
import
sys
import
sys
...
@@ -118,6 +118,7 @@ class GCTests(unittest.TestCase):
...
@@ -118,6 +118,7 @@ class GCTests(unittest.TestCase):
del
a
del
a
self
.
assertNotEqual
(
gc
.
collect
(),
0
)
self
.
assertNotEqual
(
gc
.
collect
(),
0
)
@
requires_type_collecting
def
test_newinstance
(
self
):
def
test_newinstance
(
self
):
class
A
(
object
):
class
A
(
object
):
pass
pass
...
@@ -678,6 +679,7 @@ class GCTests(unittest.TestCase):
...
@@ -678,6 +679,7 @@ class GCTests(unittest.TestCase):
stderr
=
run_command
(
code
%
"gc.DEBUG_SAVEALL"
)
stderr
=
run_command
(
code
%
"gc.DEBUG_SAVEALL"
)
self
.
assertNotIn
(
b"uncollectable objects at shutdown"
,
stderr
)
self
.
assertNotIn
(
b"uncollectable objects at shutdown"
,
stderr
)
@
requires_type_collecting
def
test_gc_main_module_at_shutdown
(
self
):
def
test_gc_main_module_at_shutdown
(
self
):
# Create a reference cycle through the __main__ module and check
# Create a reference cycle through the __main__ module and check
# it gets collected at interpreter shutdown.
# it gets collected at interpreter shutdown.
...
@@ -692,6 +694,7 @@ class GCTests(unittest.TestCase):
...
@@ -692,6 +694,7 @@ class GCTests(unittest.TestCase):
rc
,
out
,
err
=
assert_python_ok
(
'-c'
,
code
)
rc
,
out
,
err
=
assert_python_ok
(
'-c'
,
code
)
self
.
assertEqual
(
out
.
strip
(),
b'__del__ called'
)
self
.
assertEqual
(
out
.
strip
(),
b'__del__ called'
)
@
requires_type_collecting
def
test_gc_ordinary_module_at_shutdown
(
self
):
def
test_gc_ordinary_module_at_shutdown
(
self
):
# Same as above, but with a non-__main__ module.
# Same as above, but with a non-__main__ module.
with
temp_dir
()
as
script_dir
:
with
temp_dir
()
as
script_dir
:
...
...
Lib/test/test_io.py
View file @
a793037d
...
@@ -3135,6 +3135,7 @@ class TextIOWrapperTest(unittest.TestCase):
...
@@ -3135,6 +3135,7 @@ class TextIOWrapperTest(unittest.TestCase):
"""
.
format
(
iomod
=
iomod
,
kwargs
=
kwargs
)
"""
.
format
(
iomod
=
iomod
,
kwargs
=
kwargs
)
return
assert_python_ok
(
"-c"
,
code
)
return
assert_python_ok
(
"-c"
,
code
)
@
support
.
requires_type_collecting
def
test_create_at_shutdown_without_encoding
(
self
):
def
test_create_at_shutdown_without_encoding
(
self
):
rc
,
out
,
err
=
self
.
_check_create_at_shutdown
()
rc
,
out
,
err
=
self
.
_check_create_at_shutdown
()
if
err
:
if
err
:
...
@@ -3144,6 +3145,7 @@ class TextIOWrapperTest(unittest.TestCase):
...
@@ -3144,6 +3145,7 @@ class TextIOWrapperTest(unittest.TestCase):
else
:
else
:
self
.
assertEqual
(
"ok"
,
out
.
decode
().
strip
())
self
.
assertEqual
(
"ok"
,
out
.
decode
().
strip
())
@
support
.
requires_type_collecting
def
test_create_at_shutdown_with_encoding
(
self
):
def
test_create_at_shutdown_with_encoding
(
self
):
rc
,
out
,
err
=
self
.
_check_create_at_shutdown
(
encoding
=
'utf-8'
,
rc
,
out
,
err
=
self
.
_check_create_at_shutdown
(
encoding
=
'utf-8'
,
errors
=
'strict'
)
errors
=
'strict'
)
...
...
Lib/test/test_logging.py
View file @
a793037d
...
@@ -3389,6 +3389,7 @@ class ModuleLevelMiscTest(BaseTest):
...
@@ -3389,6 +3389,7 @@ class ModuleLevelMiscTest(BaseTest):
logging.setLoggerClass(logging.Logger)
logging.setLoggerClass(logging.Logger)
self.assertEqual(logging.getLoggerClass(), logging.Logger)
self.assertEqual(logging.getLoggerClass(), logging.Logger)
@support.requires_type_collecting
def test_logging_at_shutdown(self):
def test_logging_at_shutdown(self):
# Issue #20037
# Issue #20037
code = """if 1:
code = """if 1:
...
...
Lib/test/test_module.py
View file @
a793037d
# Test the module type
# Test the module type
import
unittest
import
unittest
import
weakref
import
weakref
from
test.support
import
gc_collect
from
test.support
import
gc_collect
,
requires_type_collecting
from
test.support.script_helper
import
assert_python_ok
from
test.support.script_helper
import
assert_python_ok
import
sys
import
sys
...
@@ -101,6 +101,7 @@ class ModuleTests(unittest.TestCase):
...
@@ -101,6 +101,7 @@ class ModuleTests(unittest.TestCase):
gc_collect
()
gc_collect
()
self
.
assertEqual
(
f
().
__dict__
[
"bar"
],
4
)
self
.
assertEqual
(
f
().
__dict__
[
"bar"
],
4
)
@
requires_type_collecting
def
test_clear_dict_in_ref_cycle
(
self
):
def
test_clear_dict_in_ref_cycle
(
self
):
destroyed
=
[]
destroyed
=
[]
m
=
ModuleType
(
"foo"
)
m
=
ModuleType
(
"foo"
)
...
@@ -214,6 +215,7 @@ a = A(destroyed)"""
...
@@ -214,6 +215,7 @@ a = A(destroyed)"""
self
.
assertEqual
(
r
[
-
len
(
ends_with
):],
ends_with
,
self
.
assertEqual
(
r
[
-
len
(
ends_with
):],
ends_with
,
'{!r} does not end with {!r}'
.
format
(
r
,
ends_with
))
'{!r} does not end with {!r}'
.
format
(
r
,
ends_with
))
@
requires_type_collecting
def
test_module_finalization_at_shutdown
(
self
):
def
test_module_finalization_at_shutdown
(
self
):
# Module globals and builtins should still be available during shutdown
# Module globals and builtins should still be available during shutdown
rc
,
out
,
err
=
assert_python_ok
(
"-c"
,
"from test import final_a"
)
rc
,
out
,
err
=
assert_python_ok
(
"-c"
,
"from test import final_a"
)
...
...
Lib/test/test_sys.py
View file @
a793037d
...
@@ -803,6 +803,7 @@ class SysModuleTest(unittest.TestCase):
...
@@ -803,6 +803,7 @@ class SysModuleTest(unittest.TestCase):
c
=
sys
.
getallocatedblocks
()
c
=
sys
.
getallocatedblocks
()
self
.
assertIn
(
c
,
range
(
b
-
50
,
b
+
50
))
self
.
assertIn
(
c
,
range
(
b
-
50
,
b
+
50
))
@
test
.
support
.
requires_type_collecting
def
test_is_finalizing
(
self
):
def
test_is_finalizing
(
self
):
self
.
assertIs
(
sys
.
is_finalizing
(),
False
)
self
.
assertIs
(
sys
.
is_finalizing
(),
False
)
# Don't use the atexit module because _Py_Finalizing is only set
# Don't use the atexit module because _Py_Finalizing is only set
...
@@ -1083,9 +1084,12 @@ class SizeofTest(unittest.TestCase):
...
@@ -1083,9 +1084,12 @@ class SizeofTest(unittest.TestCase):
check
((
1
,
2
,
3
),
vsize
(
''
)
+
3
*
self
.
P
)
check
((
1
,
2
,
3
),
vsize
(
''
)
+
3
*
self
.
P
)
# type
# type
# static type: PyTypeObject
# static type: PyTypeObject
s
=
vsize
(
'P2n15Pl4Pn9Pn11PIP'
)
fmt
=
'P2n15Pl4Pn9Pn11PIP'
if
hasattr
(
sys
,
'getcounts'
):
fmt
+=
'3n2P'
s
=
vsize
(
fmt
)
check
(
int
,
s
)
check
(
int
,
s
)
s
=
vsize
(
'P2n15Pl4Pn9Pn11PIP'
# PyTypeObject
s
=
vsize
(
fmt
+
# PyTypeObject
'3P'
# PyAsyncMethods
'3P'
# PyAsyncMethods
'36P'
# PyNumberMethods
'36P'
# PyNumberMethods
'3P'
# PyMappingMethods
'3P'
# PyMappingMethods
...
...
Lib/test/test_threading.py
View file @
a793037d
...
@@ -3,7 +3,8 @@ Tests for the threading module.
...
@@ -3,7 +3,8 @@ Tests for the threading module.
"""
"""
import
test.support
import
test.support
from
test.support
import
verbose
,
strip_python_stderr
,
import_module
,
cpython_only
from
test.support
import
(
verbose
,
import_module
,
cpython_only
,
requires_type_collecting
)
from
test.support.script_helper
import
assert_python_ok
,
assert_python_failure
from
test.support.script_helper
import
assert_python_ok
,
assert_python_failure
import
random
import
random
...
@@ -987,6 +988,7 @@ class ThreadingExceptionTests(BaseTestCase):
...
@@ -987,6 +988,7 @@ class ThreadingExceptionTests(BaseTestCase):
self
.
assertIn
(
"ZeroDivisionError"
,
err
)
self
.
assertIn
(
"ZeroDivisionError"
,
err
)
self
.
assertNotIn
(
"Unhandled exception"
,
err
)
self
.
assertNotIn
(
"Unhandled exception"
,
err
)
@
requires_type_collecting
def
test_print_exception_stderr_is_none_1
(
self
):
def
test_print_exception_stderr_is_none_1
(
self
):
script
=
r"""if True:
script
=
r"""if True:
import sys
import sys
...
...
Lib/test/test_traceback.py
View file @
a793037d
...
@@ -178,6 +178,7 @@ class SyntaxTracebackCases(unittest.TestCase):
...
@@ -178,6 +178,7 @@ class SyntaxTracebackCases(unittest.TestCase):
# Issue #18960: coding spec should has no effect
# Issue #18960: coding spec should has no effect
do_test
(
"0
\
n
# coding: GBK
\
n
"
,
"h
\
xe9
ho"
,
'utf-8'
,
5
)
do_test
(
"0
\
n
# coding: GBK
\
n
"
,
"h
\
xe9
ho"
,
'utf-8'
,
5
)
@
support
.
requires_type_collecting
def
test_print_traceback_at_exit
(
self
):
def
test_print_traceback_at_exit
(
self
):
# Issue #22599: Ensure that it is possible to use the traceback module
# Issue #22599: Ensure that it is possible to use the traceback module
# to display an exception at Python exit
# to display an exception at Python exit
...
...
Lib/test/test_warnings/__init__.py
View file @
a793037d
...
@@ -990,6 +990,7 @@ class BootstrapTest(unittest.TestCase):
...
@@ -990,6 +990,7 @@ class BootstrapTest(unittest.TestCase):
class
FinalizationTest
(
unittest
.
TestCase
):
class
FinalizationTest
(
unittest
.
TestCase
):
@
support
.
requires_type_collecting
def
test_finalization
(
self
):
def
test_finalization
(
self
):
# Issue #19421: warnings.warn() should not crash
# Issue #19421: warnings.warn() should not crash
# during Python finalization
# during Python finalization
...
...
Lib/test/test_weakref.py
View file @
a793037d
...
@@ -589,6 +589,7 @@ class ReferencesTestCase(TestBase):
...
@@ -589,6 +589,7 @@ class ReferencesTestCase(TestBase):
del
c1
,
c2
,
C
,
D
del
c1
,
c2
,
C
,
D
gc
.
collect
()
gc
.
collect
()
@
support
.
requires_type_collecting
def
test_callback_in_cycle_resurrection
(
self
):
def
test_callback_in_cycle_resurrection
(
self
):
import
gc
import
gc
...
...
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