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
630e69cd
Kaydet (Commit)
630e69cd
authored
Şub 09, 2001
tarafından
Eric S. Raymond
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
String method conversion.
üst
373c55e5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
16 deletions
+11
-16
doctest.py
Lib/doctest.py
+11
-16
No files found.
Lib/doctest.py
Dosyayı görüntüle @
630e69cd
# Module doctest version 0.9.
6
# Module doctest version 0.9.
7
# Released to the public domain 16-Jan-2001,
# Released to the public domain 16-Jan-2001,
# by Tim Peters (tim.one@home.com).
# by Tim Peters (tim.one@home.com).
...
@@ -345,6 +345,8 @@ Test passed.
...
@@ -345,6 +345,8 @@ Test passed.
# examples no longer worked *exactly* as advertised, due to minor
# examples no longer worked *exactly* as advertised, due to minor
# language changes, and running doctest on itself pointed that out.
# language changes, and running doctest on itself pointed that out.
# Hard to think of a better example of why this is useful <wink>.
# Hard to think of a better example of why this is useful <wink>.
# 0,9,7 9-Feb-2001
# string method conversion
__version__
=
0
,
9
,
6
__version__
=
0
,
9
,
6
...
@@ -355,13 +357,6 @@ _ModuleType = types.ModuleType
...
@@ -355,13 +357,6 @@ _ModuleType = types.ModuleType
_StringType
=
types
.
StringType
_StringType
=
types
.
StringType
del
types
del
types
import
string
_string_find
=
string
.
find
_string_join
=
string
.
join
_string_split
=
string
.
split
_string_rindex
=
string
.
rindex
del
string
import
re
import
re
PS1
=
">>>"
PS1
=
">>>"
PS2
=
"..."
PS2
=
"..."
...
@@ -384,7 +379,7 @@ def _extract_examples(s):
...
@@ -384,7 +379,7 @@ def _extract_examples(s):
isPS1
,
isPS2
=
_isPS1
,
_isPS2
isPS1
,
isPS2
=
_isPS1
,
_isPS2
isEmpty
,
isComment
=
_isEmpty
,
_isComment
isEmpty
,
isComment
=
_isEmpty
,
_isComment
examples
=
[]
examples
=
[]
lines
=
_string_split
(
s
,
"
\n
"
)
lines
=
s
.
split
(
"
\n
"
)
i
,
n
=
0
,
len
(
lines
)
i
,
n
=
0
,
len
(
lines
)
while
i
<
n
:
while
i
<
n
:
line
=
lines
[
i
]
line
=
lines
[
i
]
...
@@ -422,7 +417,7 @@ def _extract_examples(s):
...
@@ -422,7 +417,7 @@ def _extract_examples(s):
# get rid of useless null line from trailing empty "..."
# get rid of useless null line from trailing empty "..."
if
source
[
-
1
]
==
""
:
if
source
[
-
1
]
==
""
:
del
source
[
-
1
]
del
source
[
-
1
]
source
=
_string_join
(
source
,
"
\n
"
)
+
"
\n
"
source
=
"
\n
"
.
join
(
source
)
+
"
\n
"
# suck up response
# suck up response
if
isPS1
(
line
)
or
isEmpty
(
line
):
if
isPS1
(
line
)
or
isEmpty
(
line
):
expect
=
""
expect
=
""
...
@@ -437,7 +432,7 @@ def _extract_examples(s):
...
@@ -437,7 +432,7 @@ def _extract_examples(s):
line
=
lines
[
i
]
line
=
lines
[
i
]
if
isPS1
(
line
)
or
isEmpty
(
line
):
if
isPS1
(
line
)
or
isEmpty
(
line
):
break
break
expect
=
_string_join
(
expect
,
"
\n
"
)
+
"
\n
"
expect
=
"
\n
"
.
join
(
expect
)
+
"
\n
"
examples
.
append
(
(
source
,
expect
,
lineno
)
)
examples
.
append
(
(
source
,
expect
,
lineno
)
)
return
examples
return
examples
...
@@ -449,7 +444,7 @@ class _SpoofOut:
...
@@ -449,7 +444,7 @@ class _SpoofOut:
def
write
(
self
,
s
):
def
write
(
self
,
s
):
self
.
buf
.
append
(
s
)
self
.
buf
.
append
(
s
)
def
get
(
self
):
def
get
(
self
):
return
_string_join
(
self
.
buf
,
""
)
return
""
.
join
(
self
.
buf
)
def
clear
(
self
):
def
clear
(
self
):
self
.
buf
=
[]
self
.
buf
=
[]
def
flush
(
self
):
def
flush
(
self
):
...
@@ -464,7 +459,7 @@ def _tag_out(printer, *tag_msg_pairs):
...
@@ -464,7 +459,7 @@ def _tag_out(printer, *tag_msg_pairs):
printer
(
tag
+
":"
)
printer
(
tag
+
":"
)
msg_has_nl
=
msg
[
-
1
:]
==
"
\n
"
msg_has_nl
=
msg
[
-
1
:]
==
"
\n
"
msg_has_two_nl
=
msg_has_nl
and
\
msg_has_two_nl
=
msg_has_nl
and
\
_string_find
(
msg
,
"
\n
"
)
<
len
(
msg
)
-
1
msg
.
find
(
"
\n
"
)
<
len
(
msg
)
-
1
if
len
(
tag
)
+
len
(
msg
)
<
76
and
not
msg_has_two_nl
:
if
len
(
tag
)
+
len
(
msg
)
<
76
and
not
msg_has_two_nl
:
printer
(
" "
)
printer
(
" "
)
else
:
else
:
...
@@ -494,10 +489,10 @@ def _run_examples_inner(out, fakeout, examples, globs, verbose, name):
...
@@ -494,10 +489,10 @@ def _run_examples_inner(out, fakeout, examples, globs, verbose, name):
state
=
OK
state
=
OK
except
:
except
:
# See whether the exception was expected.
# See whether the exception was expected.
if
_string_find
(
want
,
"Traceback (innermost last):
\n
"
)
==
0
:
if
want
.
find
(
"Traceback (innermost last):
\n
"
)
==
0
:
# Only compare exception type and value - the rest of
# Only compare exception type and value - the rest of
# the traceback isn't necessary.
# the traceback isn't necessary.
want
=
_string_split
(
want
,
'
\n
'
)[
-
2
]
+
'
\n
'
want
=
want
.
split
(
'
\n
'
)[
-
2
]
+
'
\n
'
exc_type
,
exc_val
,
exc_tb
=
sys
.
exc_info
()
exc_type
,
exc_val
,
exc_tb
=
sys
.
exc_info
()
got
=
traceback
.
format_exception_only
(
exc_type
,
exc_val
)[
0
]
got
=
traceback
.
format_exception_only
(
exc_type
,
exc_val
)[
0
]
state
=
OK
state
=
OK
...
@@ -960,7 +955,7 @@ see its docs for details.
...
@@ -960,7 +955,7 @@ see its docs for details.
def
__runone
(
self
,
target
,
name
):
def
__runone
(
self
,
target
,
name
):
if
"."
in
name
:
if
"."
in
name
:
i
=
_string_rindex
(
name
,
"."
)
i
=
name
.
rindex
(
"."
)
prefix
,
base
=
name
[:
i
],
name
[
i
+
1
:]
prefix
,
base
=
name
[:
i
],
name
[
i
+
1
:]
else
:
else
:
prefix
,
base
=
""
,
base
prefix
,
base
=
""
,
base
...
...
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