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
711bf30b
Kaydet (Commit)
711bf30b
authored
Nis 25, 2006
tarafından
Tim Peters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #1475231: add a new SKIP doctest option, thanks to
Edward Loper.
üst
e96b229d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
0 deletions
+47
-0
libdoctest.tex
Doc/lib/libdoctest.tex
+15
-0
doctest.py
Lib/doctest.py
+9
-0
test_doctest.py
Lib/test/test_doctest.py
+19
-0
NEWS
Misc/NEWS
+4
-0
No files found.
Doc/lib/libdoctest.tex
Dosyayı görüntüle @
711bf30b
...
@@ -616,6 +616,20 @@ TypeError: object doesn't support item assignment
...
@@ -616,6 +616,20 @@ TypeError: object doesn't support item assignment
\end{datadesc}
\end{datadesc}
\begin{datadesc}
{
SKIP
}
When specified, do not run the example at all. This can be useful
in contexts where doctest examples serve as both documentation and
test cases, and an example should be included for documentation
purposes, but should not be checked. E.g., the example's output
might be random; or the example might depend on resources which
would be unavailable to the test driver.
The SKIP flag can also be used for temporarily "commenting out"
examples.
\end{datadesc}
\begin{datadesc}
{
COMPARISON
_
FLAGS
}
\begin{datadesc}
{
COMPARISON
_
FLAGS
}
A bitmask or'ing together all the comparison flags above.
A bitmask or'ing together all the comparison flags above.
\end{datadesc}
\end{datadesc}
...
@@ -744,6 +758,7 @@ can be useful.
...
@@ -744,6 +758,7 @@ can be useful.
were added; by default
\code
{
<BLANKLINE>
}
in expected output
were added; by default
\code
{
<BLANKLINE>
}
in expected output
matches an empty line in actual output; and doctest directives
matches an empty line in actual output; and doctest directives
were added]
{
2.4
}
were added]
{
2.4
}
\versionchanged
[Constant \constant{SKIP} was added]
{
2.5
}
There's also a way to register new option flag names, although this
There's also a way to register new option flag names, although this
isn't useful unless you intend to extend
\refmodule
{
doctest
}
internals
isn't useful unless you intend to extend
\refmodule
{
doctest
}
internals
...
...
Lib/doctest.py
Dosyayı görüntüle @
711bf30b
...
@@ -54,6 +54,7 @@ __all__ = [
...
@@ -54,6 +54,7 @@ __all__ = [
'DONT_ACCEPT_BLANKLINE'
,
'DONT_ACCEPT_BLANKLINE'
,
'NORMALIZE_WHITESPACE'
,
'NORMALIZE_WHITESPACE'
,
'ELLIPSIS'
,
'ELLIPSIS'
,
'SKIP'
,
'IGNORE_EXCEPTION_DETAIL'
,
'IGNORE_EXCEPTION_DETAIL'
,
'COMPARISON_FLAGS'
,
'COMPARISON_FLAGS'
,
'REPORT_UDIFF'
,
'REPORT_UDIFF'
,
...
@@ -136,12 +137,14 @@ DONT_ACCEPT_TRUE_FOR_1 = register_optionflag('DONT_ACCEPT_TRUE_FOR_1')
...
@@ -136,12 +137,14 @@ DONT_ACCEPT_TRUE_FOR_1 = register_optionflag('DONT_ACCEPT_TRUE_FOR_1')
DONT_ACCEPT_BLANKLINE
=
register_optionflag
(
'DONT_ACCEPT_BLANKLINE'
)
DONT_ACCEPT_BLANKLINE
=
register_optionflag
(
'DONT_ACCEPT_BLANKLINE'
)
NORMALIZE_WHITESPACE
=
register_optionflag
(
'NORMALIZE_WHITESPACE'
)
NORMALIZE_WHITESPACE
=
register_optionflag
(
'NORMALIZE_WHITESPACE'
)
ELLIPSIS
=
register_optionflag
(
'ELLIPSIS'
)
ELLIPSIS
=
register_optionflag
(
'ELLIPSIS'
)
SKIP
=
register_optionflag
(
'SKIP'
)
IGNORE_EXCEPTION_DETAIL
=
register_optionflag
(
'IGNORE_EXCEPTION_DETAIL'
)
IGNORE_EXCEPTION_DETAIL
=
register_optionflag
(
'IGNORE_EXCEPTION_DETAIL'
)
COMPARISON_FLAGS
=
(
DONT_ACCEPT_TRUE_FOR_1
|
COMPARISON_FLAGS
=
(
DONT_ACCEPT_TRUE_FOR_1
|
DONT_ACCEPT_BLANKLINE
|
DONT_ACCEPT_BLANKLINE
|
NORMALIZE_WHITESPACE
|
NORMALIZE_WHITESPACE
|
ELLIPSIS
|
ELLIPSIS
|
SKIP
|
IGNORE_EXCEPTION_DETAIL
)
IGNORE_EXCEPTION_DETAIL
)
REPORT_UDIFF
=
register_optionflag
(
'REPORT_UDIFF'
)
REPORT_UDIFF
=
register_optionflag
(
'REPORT_UDIFF'
)
...
@@ -1233,6 +1236,10 @@ class DocTestRunner:
...
@@ -1233,6 +1236,10 @@ class DocTestRunner:
else
:
else
:
self
.
optionflags
&=
~
optionflag
self
.
optionflags
&=
~
optionflag
# If 'SKIP' is set, then skip this example.
if
self
.
optionflags
&
SKIP
:
continue
# Record that we started this example.
# Record that we started this example.
tries
+=
1
tries
+=
1
if
not
quiet
:
if
not
quiet
:
...
@@ -1792,6 +1799,7 @@ def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None,
...
@@ -1792,6 +1799,7 @@ def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None,
DONT_ACCEPT_BLANKLINE
DONT_ACCEPT_BLANKLINE
NORMALIZE_WHITESPACE
NORMALIZE_WHITESPACE
ELLIPSIS
ELLIPSIS
SKIP
IGNORE_EXCEPTION_DETAIL
IGNORE_EXCEPTION_DETAIL
REPORT_UDIFF
REPORT_UDIFF
REPORT_CDIFF
REPORT_CDIFF
...
@@ -1914,6 +1922,7 @@ def testfile(filename, module_relative=True, name=None, package=None,
...
@@ -1914,6 +1922,7 @@ def testfile(filename, module_relative=True, name=None, package=None,
DONT_ACCEPT_BLANKLINE
DONT_ACCEPT_BLANKLINE
NORMALIZE_WHITESPACE
NORMALIZE_WHITESPACE
ELLIPSIS
ELLIPSIS
SKIP
IGNORE_EXCEPTION_DETAIL
IGNORE_EXCEPTION_DETAIL
REPORT_UDIFF
REPORT_UDIFF
REPORT_CDIFF
REPORT_CDIFF
...
...
Lib/test/test_doctest.py
Dosyayı görüntüle @
711bf30b
...
@@ -1079,6 +1079,25 @@ output to match any substring in the actual output:
...
@@ -1079,6 +1079,25 @@ output to match any substring in the actual output:
... # doctest: +NORMALIZE_WHITESPACE
... # doctest: +NORMALIZE_WHITESPACE
[0, 1, ..., 18, 19]
[0, 1, ..., 18, 19]
The SKIP flag causes an example to be skipped entirely. I.e., the
example is not run. It can be useful in contexts where doctest
examples serve as both documentation and test cases, and an example
should be included for documentation purposes, but should not be
checked (e.g., because its output is random, or depends on resources
which would be unavailable.) The SKIP flag can also be used for
'commenting out' broken examples.
>>> import unavailable_resource # doctest: +SKIP
>>> unavailable_resource.do_something() # doctest: +SKIP
>>> unavailable_resource.blow_up() # doctest: +SKIP
Traceback (most recent call last):
...
UncheckedBlowUpError: Nobody checks me.
>>> import random
>>> print random.random() # doctest: +SKIP
0.721216923889
The REPORT_UDIFF flag causes failures that involve multi-line expected
The REPORT_UDIFF flag causes failures that involve multi-line expected
and actual outputs to be displayed using a unified diff:
and actual outputs to be displayed using a unified diff:
...
...
Misc/NEWS
Dosyayı görüntüle @
711bf30b
...
@@ -86,6 +86,10 @@ Extension Modules
...
@@ -86,6 +86,10 @@ Extension Modules
Library
Library
-------
-------
- Patch #1475231: ``doctest`` has a new ``SKIP`` option, which causes
a doctest to be skipped (the code is not run, and the expected output
or exception is ignored).
- Fixed contextlib.nested to cope with exceptions being raised and
- Fixed contextlib.nested to cope with exceptions being raised and
caught inside exit handlers.
caught inside exit handlers.
...
...
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