Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
2feb6425
Kaydet (Commit)
2feb6425
authored
Şub 11, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #26325: Added test.support.check_no_resource_warning() to check that
no ResourceWarning is emitted.
üst
885bdc49
94a619d4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
20 deletions
+32
-20
__init__.py
Lib/test/support/__init__.py
+23
-1
test_subprocess.py
Lib/test/test_asyncio/test_subprocess.py
+1
-2
test_io.py
Lib/test/test_io.py
+3
-9
test_xml_etree.py
Lib/test/test_xml_etree.py
+2
-8
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/support/__init__.py
Dosyayı görüntüle @
2feb6425
...
@@ -102,7 +102,8 @@ __all__ = [
...
@@ -102,7 +102,8 @@ __all__ = [
# threads
# threads
"threading_setup"
,
"threading_cleanup"
,
"reap_threads"
,
"start_threads"
,
"threading_setup"
,
"threading_cleanup"
,
"reap_threads"
,
"start_threads"
,
# miscellaneous
# miscellaneous
"check_warnings"
,
"EnvironmentVarGuard"
,
"run_with_locale"
,
"swap_item"
,
"check_warnings"
,
"check_no_resource_warning"
,
"EnvironmentVarGuard"
,
"run_with_locale"
,
"swap_item"
,
"swap_attr"
,
"Matcher"
,
"set_memlimit"
,
"SuppressCrashReport"
,
"sortdict"
,
"swap_attr"
,
"Matcher"
,
"set_memlimit"
,
"SuppressCrashReport"
,
"sortdict"
,
"run_with_tz"
,
"run_with_tz"
,
]
]
...
@@ -1149,6 +1150,27 @@ def check_warnings(*filters, **kwargs):
...
@@ -1149,6 +1150,27 @@ def check_warnings(*filters, **kwargs):
return
_filterwarnings
(
filters
,
quiet
)
return
_filterwarnings
(
filters
,
quiet
)
@contextlib.contextmanager
def
check_no_resource_warning
(
testcase
):
"""Context manager to check that no ResourceWarning is emitted.
Usage:
with check_no_resource_warning(self):
f = open(...)
...
del f
You must remove the object which may emit ResourceWarning before
the end of the context manager.
"""
with
warnings
.
catch_warnings
(
record
=
True
)
as
warns
:
warnings
.
filterwarnings
(
'always'
,
category
=
ResourceWarning
)
yield
gc_collect
()
testcase
.
assertEqual
(
warns
,
[])
class
CleanImport
(
object
):
class
CleanImport
(
object
):
"""Context manager to force import to return a new module reference.
"""Context manager to force import to return a new module reference.
...
...
Lib/test/test_asyncio/test_subprocess.py
Dosyayı görüntüle @
2feb6425
...
@@ -427,10 +427,9 @@ class SubprocessMixin:
...
@@ -427,10 +427,9 @@ class SubprocessMixin:
create
=
asyncio
.
create_subprocess_exec
(
sys
.
executable
,
'-c'
,
create
=
asyncio
.
create_subprocess_exec
(
sys
.
executable
,
'-c'
,
'pass'
,
loop
=
self
.
loop
)
'pass'
,
loop
=
self
.
loop
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
warns
:
with
support
.
check_no_resource_warning
(
self
)
:
with
self
.
assertRaises
(
exc
):
with
self
.
assertRaises
(
exc
):
self
.
loop
.
run_until_complete
(
create
)
self
.
loop
.
run_until_complete
(
create
)
self
.
assertEqual
(
warns
,
[])
if
sys
.
platform
!=
'win32'
:
if
sys
.
platform
!=
'win32'
:
...
...
Lib/test/test_io.py
Dosyayı görüntüle @
2feb6425
...
@@ -681,18 +681,14 @@ class IOTest(unittest.TestCase):
...
@@ -681,18 +681,14 @@ class IOTest(unittest.TestCase):
f2
.
readline
()
f2
.
readline
()
def
test_nonbuffered_textio
(
self
):
def
test_nonbuffered_textio
(
self
):
with
warnings
.
catch_warnings
(
record
=
True
)
as
recorded
:
with
support
.
check_no_resource_warning
(
self
)
:
with
self
.
assertRaises
(
ValueError
):
with
self
.
assertRaises
(
ValueError
):
self
.
open
(
support
.
TESTFN
,
'w'
,
buffering
=
0
)
self
.
open
(
support
.
TESTFN
,
'w'
,
buffering
=
0
)
support
.
gc_collect
()
self
.
assertEqual
(
recorded
,
[])
def
test_invalid_newline
(
self
):
def
test_invalid_newline
(
self
):
with
warnings
.
catch_warnings
(
record
=
True
)
as
recorded
:
with
support
.
check_no_resource_warning
(
self
)
:
with
self
.
assertRaises
(
ValueError
):
with
self
.
assertRaises
(
ValueError
):
self
.
open
(
support
.
TESTFN
,
'w'
,
newline
=
'invalid'
)
self
.
open
(
support
.
TESTFN
,
'w'
,
newline
=
'invalid'
)
support
.
gc_collect
()
self
.
assertEqual
(
recorded
,
[])
class
CIOTest
(
IOTest
):
class
CIOTest
(
IOTest
):
...
@@ -3366,10 +3362,8 @@ class MiscIOTest(unittest.TestCase):
...
@@ -3366,10 +3362,8 @@ class MiscIOTest(unittest.TestCase):
# When using closefd=False, there's no warning
# When using closefd=False, there's no warning
r
,
w
=
os
.
pipe
()
r
,
w
=
os
.
pipe
()
fds
+=
r
,
w
fds
+=
r
,
w
with
warnings
.
catch_warnings
(
record
=
True
)
as
recorded
:
with
support
.
check_no_resource_warning
(
self
)
:
open
(
r
,
*
args
,
closefd
=
False
,
**
kwargs
)
open
(
r
,
*
args
,
closefd
=
False
,
**
kwargs
)
support
.
gc_collect
()
self
.
assertEqual
(
recorded
,
[])
def
test_warn_on_dealloc_fd
(
self
):
def
test_warn_on_dealloc_fd
(
self
):
self
.
_check_warn_on_dealloc_fd
(
"rb"
,
buffering
=
0
)
self
.
_check_warn_on_dealloc_fd
(
"rb"
,
buffering
=
0
)
...
...
Lib/test/test_xml_etree.py
Dosyayı görüntüle @
2feb6425
...
@@ -569,14 +569,11 @@ class ElementTreeTest(unittest.TestCase):
...
@@ -569,14 +569,11 @@ class ElementTreeTest(unittest.TestCase):
self
.
assertFalse
(
f
.
closed
)
self
.
assertFalse
(
f
.
closed
)
self
.
assertEqual
(
str
(
cm
.
exception
),
"unknown event 'bogus'"
)
self
.
assertEqual
(
str
(
cm
.
exception
),
"unknown event 'bogus'"
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
with
support
.
check_no_resource_warning
(
self
):
warnings
.
filterwarnings
(
"always"
,
category
=
ResourceWarning
)
with
self
.
assertRaises
(
ValueError
)
as
cm
:
with
self
.
assertRaises
(
ValueError
)
as
cm
:
iterparse
(
SIMPLE_XMLFILE
,
events
)
iterparse
(
SIMPLE_XMLFILE
,
events
)
self
.
assertEqual
(
str
(
cm
.
exception
),
"unknown event 'bogus'"
)
self
.
assertEqual
(
str
(
cm
.
exception
),
"unknown event 'bogus'"
)
del
cm
del
cm
support
.
gc_collect
()
self
.
assertEqual
(
w
,
[])
source
=
io
.
BytesIO
(
source
=
io
.
BytesIO
(
b
"<?xml version='1.0' encoding='iso-8859-1'?>
\n
"
b
"<?xml version='1.0' encoding='iso-8859-1'?>
\n
"
...
@@ -603,15 +600,12 @@ class ElementTreeTest(unittest.TestCase):
...
@@ -603,15 +600,12 @@ class ElementTreeTest(unittest.TestCase):
it
=
iterparse
(
TESTFN
)
it
=
iterparse
(
TESTFN
)
action
,
elem
=
next
(
it
)
action
,
elem
=
next
(
it
)
self
.
assertEqual
((
action
,
elem
.
tag
),
(
'end'
,
'document'
))
self
.
assertEqual
((
action
,
elem
.
tag
),
(
'end'
,
'document'
))
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
with
support
.
check_no_resource_warning
(
self
):
warnings
.
filterwarnings
(
"always"
,
category
=
ResourceWarning
)
with
self
.
assertRaises
(
ET
.
ParseError
)
as
cm
:
with
self
.
assertRaises
(
ET
.
ParseError
)
as
cm
:
next
(
it
)
next
(
it
)
self
.
assertEqual
(
str
(
cm
.
exception
),
self
.
assertEqual
(
str
(
cm
.
exception
),
'junk after document element: line 1, column 12'
)
'junk after document element: line 1, column 12'
)
del
cm
,
it
del
cm
,
it
support
.
gc_collect
()
self
.
assertEqual
(
w
,
[])
def
test_writefile
(
self
):
def
test_writefile
(
self
):
elem
=
ET
.
Element
(
"tag"
)
elem
=
ET
.
Element
(
"tag"
)
...
...
Misc/NEWS
Dosyayı görüntüle @
2feb6425
...
@@ -673,6 +673,9 @@ Documentation
...
@@ -673,6 +673,9 @@ Documentation
Tests
Tests
-----
-----
- Issue #26325: Added test.support.check_no_resource_warning() to check that
no ResourceWarning is emitted.
- Issue #25940: Changed test_ssl to use self-signed.pythontest.net. This
- Issue #25940: Changed test_ssl to use self-signed.pythontest.net. This
avoids relying on svn.python.org, which recently changed root certificate.
avoids relying on svn.python.org, which recently changed root certificate.
...
...
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