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
f9a07f2e
Kaydet (Commit)
f9a07f2e
authored
Ara 04, 2013
tarafından
Tim Peters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #19138: doctest's IGNORE_EXCEPTION_DETAIL now allows no detail at all.
üst
88c29877
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
4 deletions
+60
-4
doctest.py
Lib/doctest.py
+29
-4
test_doctest.py
Lib/test/test_doctest.py
+27
-0
NEWS
Misc/NEWS
+4
-0
No files found.
Lib/doctest.py
Dosyayı görüntüle @
f9a07f2e
...
@@ -318,6 +318,32 @@ def _comment_line(line):
...
@@ -318,6 +318,32 @@ def _comment_line(line):
else
:
else
:
return
'#'
return
'#'
def
_strip_exception_details
(
msg
):
# Support for IGNORE_EXCEPTION_DETAIL.
# Get rid of everything except the exception name; in particular, drop
# the possibly dotted module path (if any) and the exception message (if
# any). We assume that a colon is never part of a dotted name, or of an
# exception name.
# E.g., given
# "foo.bar.MyError: la di da"
# return "MyError"
# Or for "abc.def" or "abc.def:\n" return "def".
start
,
end
=
0
,
len
(
msg
)
# The exception name must appear on the first line.
i
=
msg
.
find
(
"
\n
"
)
if
i
>=
0
:
end
=
i
# retain up to the first colon (if any)
i
=
msg
.
find
(
':'
,
0
,
end
)
if
i
>=
0
:
end
=
i
# retain just the exception name
i
=
msg
.
rfind
(
'.'
,
0
,
end
)
if
i
>=
0
:
start
=
i
+
1
return
msg
[
start
:
end
]
class
_OutputRedirectingPdb
(
pdb
.
Pdb
):
class
_OutputRedirectingPdb
(
pdb
.
Pdb
):
"""
"""
A specialized version of the python debugger that redirects stdout
A specialized version of the python debugger that redirects stdout
...
@@ -1325,10 +1351,9 @@ class DocTestRunner:
...
@@ -1325,10 +1351,9 @@ class DocTestRunner:
# Another chance if they didn't care about the detail.
# Another chance if they didn't care about the detail.
elif
self
.
optionflags
&
IGNORE_EXCEPTION_DETAIL
:
elif
self
.
optionflags
&
IGNORE_EXCEPTION_DETAIL
:
m1
=
re
.
match
(
r'(?:[^:]*\.)?([^:]*:)'
,
example
.
exc_msg
)
if
check
(
_strip_exception_details
(
example
.
exc_msg
),
m2
=
re
.
match
(
r'(?:[^:]*\.)?([^:]*:)'
,
exc_msg
)
_strip_exception_details
(
exc_msg
),
if
m1
and
m2
and
check
(
m1
.
group
(
1
),
m2
.
group
(
1
),
self
.
optionflags
):
self
.
optionflags
):
outcome
=
SUCCESS
outcome
=
SUCCESS
# Report the outcome.
# Report the outcome.
...
...
Lib/test/test_doctest.py
Dosyayı görüntüle @
f9a07f2e
...
@@ -1054,6 +1054,33 @@ But IGNORE_EXCEPTION_DETAIL does not allow a mismatch in the exception type:
...
@@ -1054,6 +1054,33 @@ But IGNORE_EXCEPTION_DETAIL does not allow a mismatch in the exception type:
ValueError: message
ValueError: message
TestResults(failed=1, attempted=1)
TestResults(failed=1, attempted=1)
If the exception does not have a message, you can still use
IGNORE_EXCEPTION_DETAIL to normalize the modules between Python 2 and 3:
>>> def f(x):
... r'''
... >>> from http.client import HTTPException
... >>> raise HTTPException() #doctest: +IGNORE_EXCEPTION_DETAIL
... Traceback (most recent call last):
... foo.bar.HTTPException
... '''
>>> test = doctest.DocTestFinder().find(f)[0]
>>> doctest.DocTestRunner(verbose=False).run(test)
TestResults(failed=0, attempted=2)
Note that a trailing colon doesn't matter either:
>>> def f(x):
... r'''
... >>> from http.client import HTTPException
... >>> raise HTTPException() #doctest: +IGNORE_EXCEPTION_DETAIL
... Traceback (most recent call last):
... foo.bar.HTTPException:
... '''
>>> test = doctest.DocTestFinder().find(f)[0]
>>> doctest.DocTestRunner(verbose=False).run(test)
TestResults(failed=0, attempted=2)
If an exception is raised but not expected, then it is reported as an
If an exception is raised but not expected, then it is reported as an
unexpected exception:
unexpected exception:
...
...
Misc/NEWS
Dosyayı görüntüle @
f9a07f2e
...
@@ -18,6 +18,10 @@ Core and Builtins
...
@@ -18,6 +18,10 @@ Core and Builtins
Library
Library
-------
-------
- Issue #19138: doctest'
s
IGNORE_EXCEPTION_DETAIL
now
allows
a
match
when
no
exception
detail
exists
(
no
colon
following
the
exception
's name, or
a colon does follow but no text follows the colon).
- Issue #19827: On UNIX, setblocking() and settimeout() methods of
- Issue #19827: On UNIX, setblocking() and settimeout() methods of
socket.socket can now avoid a second syscall if the ioctl() function can be
socket.socket can now avoid a second syscall if the ioctl() function can be
used, or if the non-blocking flag of the socket is unchanged.
used, or if the non-blocking flag of the socket is unchanged.
...
...
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