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
469a05fe
Kaydet (Commit)
469a05fe
authored
Ock 24, 2010
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
remove archaic functions from test_support
üst
b0f5adc3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
69 deletions
+42
-69
string_tests.py
Lib/test/string_tests.py
+9
-9
test_pprint.py
Lib/test/test_pprint.py
+32
-35
test_support.py
Lib/test/test_support.py
+1
-25
No files found.
Lib/test/string_tests.py
Dosyayı görüntüle @
469a05fe
...
...
@@ -973,15 +973,15 @@ class MixinStrUnicodeUserStringTest:
self
.
checkraises
(
TypeError
,
'hello'
,
'endswith'
,
(
42
,))
def
test___contains__
(
self
):
self
.
checkequal
(
True
,
''
,
'__contains__'
,
''
)
# vereq('' in '', True)
self
.
checkequal
(
True
,
'abc'
,
'__contains__'
,
''
)
# vereq('' in 'abc', True)
self
.
checkequal
(
False
,
'abc'
,
'__contains__'
,
'
\0
'
)
# vereq('\0' in 'abc', False)
self
.
checkequal
(
True
,
'
\0
abc'
,
'__contains__'
,
'
\0
'
)
# vereq('\0' in '\0abc', True)
self
.
checkequal
(
True
,
'abc
\0
'
,
'__contains__'
,
'
\0
'
)
# vereq('\0' in 'abc\0', True)
self
.
checkequal
(
True
,
'
\0
abc'
,
'__contains__'
,
'a'
)
# vereq('a' in '\0abc', True)
self
.
checkequal
(
True
,
'asdf'
,
'__contains__'
,
'asdf'
)
# vereq('asdf' in 'asdf', True)
self
.
checkequal
(
False
,
'asd'
,
'__contains__'
,
'asdf'
)
# vereq('asdf' in 'asd', False)
self
.
checkequal
(
False
,
''
,
'__contains__'
,
'asdf'
)
# vereq('asdf' in '', False)
self
.
checkequal
(
True
,
''
,
'__contains__'
,
''
)
self
.
checkequal
(
True
,
'abc'
,
'__contains__'
,
''
)
self
.
checkequal
(
False
,
'abc'
,
'__contains__'
,
'
\0
'
)
self
.
checkequal
(
True
,
'
\0
abc'
,
'__contains__'
,
'
\0
'
)
self
.
checkequal
(
True
,
'abc
\0
'
,
'__contains__'
,
'
\0
'
)
self
.
checkequal
(
True
,
'
\0
abc'
,
'__contains__'
,
'a'
)
self
.
checkequal
(
True
,
'asdf'
,
'__contains__'
,
'asdf'
)
self
.
checkequal
(
False
,
'asd'
,
'__contains__'
,
'asdf'
)
self
.
checkequal
(
False
,
''
,
'__contains__'
,
'asdf'
)
def
test_subscript
(
self
):
self
.
checkequal
(
u'a'
,
'abc'
,
'__getitem__'
,
0
)
...
...
Lib/test/test_pprint.py
Dosyayı görüntüle @
469a05fe
...
...
@@ -40,20 +40,19 @@ class QueryTestCase(unittest.TestCase):
def
test_basic
(
self
):
# Verify .isrecursive() and .isreadable() w/o recursion
verify
=
self
.
assertTrue
pp
=
pprint
.
PrettyPrinter
()
for
safe
in
(
2
,
2.0
,
2
j
,
"abc"
,
[
3
],
(
2
,
2
),
{
3
:
3
},
uni
(
"yaddayadda"
),
self
.
a
,
self
.
b
):
# module-level convenience functions
verify
(
not
pprint
.
isrecursive
(
safe
),
"expected not isrecursive for
%
r"
%
(
safe
,))
verify
(
pprint
.
isreadable
(
safe
),
"expected isreadable for
%
r"
%
(
safe
,))
self
.
assertFalse
(
pprint
.
isrecursive
(
safe
),
"expected not isrecursive for
%
r"
%
(
safe
,))
self
.
assertTrue
(
pprint
.
isreadable
(
safe
),
"expected isreadable for
%
r"
%
(
safe
,))
# PrettyPrinter methods
verify
(
not
pp
.
isrecursive
(
safe
),
"expected not isrecursive for
%
r"
%
(
safe
,))
verify
(
pp
.
isreadable
(
safe
),
"expected isreadable for
%
r"
%
(
safe
,))
self
.
assertFalse
(
pp
.
isrecursive
(
safe
),
"expected not isrecursive for
%
r"
%
(
safe
,))
self
.
assertTrue
(
pp
.
isreadable
(
safe
),
"expected isreadable for
%
r"
%
(
safe
,))
def
test_knotted
(
self
):
# Verify .isrecursive() and .isreadable() w/ recursion
...
...
@@ -63,14 +62,13 @@ class QueryTestCase(unittest.TestCase):
self
.
d
=
{}
self
.
d
[
0
]
=
self
.
d
[
1
]
=
self
.
d
[
2
]
=
self
.
d
verify
=
self
.
assertTrue
pp
=
pprint
.
PrettyPrinter
()
for
icky
in
self
.
a
,
self
.
b
,
self
.
d
,
(
self
.
d
,
self
.
d
):
verify
(
pprint
.
isrecursive
(
icky
),
"expected isrecursive"
)
verify
(
not
pprint
.
isreadable
(
icky
),
"expected not isreadable"
)
verify
(
pp
.
isrecursive
(
icky
),
"expected isrecursive"
)
verify
(
not
pp
.
isreadable
(
icky
),
"expected not isreadable"
)
self
.
assertTrue
(
pprint
.
isrecursive
(
icky
),
"expected isrecursive"
)
self
.
assertFalse
(
pprint
.
isreadable
(
icky
),
"expected not isreadable"
)
self
.
assertTrue
(
pp
.
isrecursive
(
icky
),
"expected isrecursive"
)
self
.
assertFalse
(
pp
.
isreadable
(
icky
),
"expected not isreadable"
)
# Break the cycles.
self
.
d
.
clear
()
...
...
@@ -79,31 +77,30 @@ class QueryTestCase(unittest.TestCase):
for
safe
in
self
.
a
,
self
.
b
,
self
.
d
,
(
self
.
d
,
self
.
d
):
# module-level convenience functions
verify
(
not
pprint
.
isrecursive
(
safe
),
"expected not isrecursive for
%
r"
%
(
safe
,))
verify
(
pprint
.
isreadable
(
safe
),
"expected isreadable for
%
r"
%
(
safe
,))
self
.
assertFalse
(
pprint
.
isrecursive
(
safe
),
"expected not isrecursive for
%
r"
%
(
safe
,))
self
.
assertTrue
(
pprint
.
isreadable
(
safe
),
"expected isreadable for
%
r"
%
(
safe
,))
# PrettyPrinter methods
verify
(
not
pp
.
isrecursive
(
safe
),
"expected not isrecursive for
%
r"
%
(
safe
,))
verify
(
pp
.
isreadable
(
safe
),
"expected isreadable for
%
r"
%
(
safe
,))
self
.
assertFalse
(
pp
.
isrecursive
(
safe
),
"expected not isrecursive for
%
r"
%
(
safe
,))
self
.
assertTrue
(
pp
.
isreadable
(
safe
),
"expected isreadable for
%
r"
%
(
safe
,))
def
test_unreadable
(
self
):
# Not recursive but not readable anyway
verify
=
self
.
assertTrue
pp
=
pprint
.
PrettyPrinter
()
for
unreadable
in
type
(
3
),
pprint
,
pprint
.
isrecursive
:
# module-level convenience functions
verify
(
not
pprint
.
isrecursive
(
unreadable
),
"expected not isrecursive for
%
r"
%
(
unreadable
,))
verify
(
not
pprint
.
isreadable
(
unreadable
),
"expected not isreadable for
%
r"
%
(
unreadable
,))
self
.
assertFalse
(
pprint
.
isrecursive
(
unreadable
),
"expected not isrecursive for
%
r"
%
(
unreadable
,))
self
.
assertFalse
(
pprint
.
isreadable
(
unreadable
),
"expected not isreadable for
%
r"
%
(
unreadable
,))
# PrettyPrinter methods
verify
(
not
pp
.
isrecursive
(
unreadable
),
"expected not isrecursive for
%
r"
%
(
unreadable
,))
verify
(
not
pp
.
isreadable
(
unreadable
),
"expected not isreadable for
%
r"
%
(
unreadable
,))
self
.
assertFalse
(
pp
.
isrecursive
(
unreadable
),
"expected not isrecursive for
%
r"
%
(
unreadable
,))
self
.
assertFalse
(
pp
.
isreadable
(
unreadable
),
"expected not isreadable for
%
r"
%
(
unreadable
,))
def
test_same_as_repr
(
self
):
# Simple objects, small containers and classes that overwrite __repr__
...
...
@@ -114,12 +111,11 @@ class QueryTestCase(unittest.TestCase):
# it sorted a dict display if and only if the display required
# multiple lines. For that reason, dicts with more than one element
# aren't tested here.
verify
=
self
.
assertTrue
for
simple
in
(
0
,
0L
,
0
+
0
j
,
0.0
,
""
,
uni
(
""
),
(),
tuple2
(),
tuple3
(),
[],
list2
(),
list3
(),
{},
dict2
(),
dict3
(),
verify
,
pprint
,
self
.
assertTrue
,
pprint
,
-
6
,
-
6L
,
-
6
-
6
j
,
-
1.5
,
"x"
,
uni
(
"x"
),
(
3
,),
[
3
],
{
3
:
6
},
(
1
,
2
),
[
3
,
4
],
{
5
:
6
},
tuple2
((
1
,
2
)),
tuple3
((
1
,
2
)),
tuple3
(
range
(
100
)),
...
...
@@ -131,8 +127,9 @@ class QueryTestCase(unittest.TestCase):
for
function
in
"pformat"
,
"saferepr"
:
f
=
getattr
(
pprint
,
function
)
got
=
f
(
simple
)
verify
(
native
==
got
,
"expected
%
s got
%
s from pprint.
%
s"
%
(
native
,
got
,
function
))
self
.
assertEqual
(
native
,
got
,
"expected
%
s got
%
s from pprint.
%
s"
%
(
native
,
got
,
function
))
def
test_basic_line_wrap
(
self
):
# verify basic line-wrapping operation
...
...
Lib/test/test_support.py
Dosyayı görüntüle @
469a05fe
...
...
@@ -22,7 +22,7 @@ __all__ = ["Error", "TestFailed", "ResourceDenied", "import_module",
"get_original_stdout"
,
"unload"
,
"unlink"
,
"rmtree"
,
"forget"
,
"is_resource_enabled"
,
"requires"
,
"find_unused_port"
,
"bind_port"
,
"fcmp"
,
"have_unicode"
,
"is_jython"
,
"TESTFN"
,
"HOST"
,
"FUZZ"
,
"findfile"
,
"
verify"
,
"vereq"
,
"
sortdict"
,
"check_syntax_error"
,
"findfile"
,
"sortdict"
,
"check_syntax_error"
,
"open_urlresource"
,
"check_warnings"
,
"CleanImport"
,
"EnvironmentVarGuard"
,
"captured_output"
,
"captured_stdout"
,
"TransientResource"
,
"transient_internet"
,
...
...
@@ -414,30 +414,6 @@ def findfile(file, here=__file__):
if
os
.
path
.
exists
(
fn
):
return
fn
return
file
def
verify
(
condition
,
reason
=
'test failed'
):
"""Verify that condition is true. If not, raise TestFailed.
The optional argument reason can be given to provide
a better error text.
"""
if
not
condition
:
raise
TestFailed
(
reason
)
def
vereq
(
a
,
b
):
"""Raise TestFailed if a == b is false.
This is better than verify(a == b) because, in case of failure, the
error message incorporates repr(a) and repr(b) so you can see the
inputs.
Note that "not (a == b)" isn't necessarily the same as "a != b"; the
former is tested.
"""
if
not
(
a
==
b
):
raise
TestFailed
(
"
%
r ==
%
r"
%
(
a
,
b
))
def
sortdict
(
dict
):
"Like repr(dict), but in sorted order."
items
=
dict
.
items
()
...
...
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