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
5d2f515d
Kaydet (Commit)
5d2f515d
authored
Haz 28, 2003
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fix markup nits
üst
c0fac96c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
libdoctest.tex
Doc/lib/libdoctest.tex
+12
-12
No files found.
Doc/lib/libdoctest.tex
Dosyayı görüntüle @
5d2f515d
...
@@ -153,7 +153,7 @@ if __name__ == "__main__":
...
@@ -153,7 +153,7 @@ if __name__ == "__main__":
\end{verbatim}
\end{verbatim}
If you want to test the module as the main module, you don't need to
If you want to test the module as the main module, you don't need to
pass M to
\function
{
testmod
}
; in this case, it will test the current
pass M to
\function
{
testmod
()
}
; in this case, it will test the current
module.
module.
Then running the module as a script causes the examples in the docstrings
Then running the module as a script causes the examples in the docstrings
...
@@ -176,11 +176,12 @@ python M.py -v
...
@@ -176,11 +176,12 @@ python M.py -v
and a detailed report of all examples tried is printed to
\code
{
stdout
}
,
and a detailed report of all examples tried is printed to
\code
{
stdout
}
,
along with assorted summaries at the end.
along with assorted summaries at the end.
You can force verbose mode by passing
\code
{
verbose=1
}
to testmod, or
You can force verbose mode by passing
\code
{
verbose=1
}
to
\function
{
testmod()
}
, or
prohibit it by passing
\code
{
verbose=0
}
. In either of those cases,
prohibit it by passing
\code
{
verbose=0
}
. In either of those cases,
\code
{
sys.argv
}
is not examined by
testmod
.
\code
{
sys.argv
}
is not examined by
\function
{
testmod()
}
.
In any case,
testmod
returns a 2-tuple of ints
\code
{
(
\var
{
f
}
,
In any case,
\function
{
testmod()
}
returns a 2-tuple of ints
\code
{
(
\var
{
f
}
,
\var
{
t
}
)
}
, where
\var
{
f
}
is the number of docstring examples that
\var
{
t
}
)
}
, where
\var
{
f
}
is the number of docstring examples that
failed and
\var
{
t
}
is the total number of docstring examples
failed and
\var
{
t
}
is the total number of docstring examples
attempted.
attempted.
...
@@ -210,8 +211,8 @@ from \module{M}'s globals are skipped, all names reached from
...
@@ -210,8 +211,8 @@ from \module{M}'s globals are skipped, all names reached from
\subsection
{
What's the Execution Context?
}
\subsection
{
What's the Execution Context?
}
By default, each time
testmod finds a docstring to test, it uses a
By default, each time
\function
{
testmod()
}
finds a docstring to test, it uses
\emph
{
copy
}
of
\module
{
M
}
's globals, so that running tests on a module
a
\emph
{
copy
}
of
\module
{
M
}
's globals, so that running tests on a module
doesn't change the module's real globals, and so that one test in
doesn't change the module's real globals, and so that one test in
\module
{
M
}
can't leave behind crumbs that accidentally allow another test
\module
{
M
}
can't leave behind crumbs that accidentally allow another test
to work. This means examples can freely use any names defined at top-level
to work. This means examples can freely use any names defined at top-level
...
@@ -400,21 +401,20 @@ def _test():
...
@@ -400,21 +401,20 @@ def _test():
\end{verbatim}
\end{verbatim}
\item
WYSIWYG isn't always the case, starting in Python 2.3. The
\item
WYSIWYG isn't always the case, starting in Python 2.3. The
string form of boolean results changed from
\code
{
"0"
}
and
string form of boolean results changed from
\code
{
'0'
}
and
\code
{
"1"
}
to
\code
{
"False"
}
and
\code
{
"True"
}
in Python 2.3.
\code
{
'1'
}
to
\code
{
'False'
}
and
\code
{
'True'
}
in Python 2.3.
This makes it clumsy to write a doctest showing boolean results that
This makes it clumsy to write a doctest showing boolean results that
passes under multiple versions of Python. In Python 2.3, by default,
passes under multiple versions of Python. In Python 2.3, by default,
and as a special case, if an expected output block consists solely
and as a special case, if an expected output block consists solely
of
\code
{
"0"
}
and the actual output block consists solely of
of
\code
{
'0'
}
and the actual output block consists solely of
\code
{
"False"
}
, that's accepted as an exact match, and similarly for
\code
{
'False'
}
, that's accepted as an exact match, and similarly for
\code
{
"1"
}
versus
\code
{
"True"
}
. This behavior can be turned off by
\code
{
'1'
}
versus
\code
{
'True'
}
. This behavior can be turned off by
passing the new (in 2.3) module constant
passing the new (in 2.3) module constant
\constant
{
DONT
_
ACCEPT
_
TRUE
_
FOR
_
1
}
as the value of
\function
{
testmod()
}
's
\constant
{
DONT
_
ACCEPT
_
TRUE
_
FOR
_
1
}
as the value of
\function
{
testmod()
}
's
new (in 2.3) optional
\var
{
optionflags
}
argument. Some years after
new (in 2.3) optional
\var
{
optionflags
}
argument. Some years after
the integer spellings of booleans are history, this hack will
the integer spellings of booleans are history, this hack will
probably be removed again.
probably be removed again.
\end{enumerate}
\end{enumerate}
...
...
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