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
5d36a55e
Kaydet (Commit)
5d36a55e
authored
Haz 03, 2005
tarafından
Tim Peters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Whitespace normalization.
üst
6b95f1d9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
195 additions
and
195 deletions
+195
-195
test_compare.py
Lib/bsddb/test/test_compare.py
+186
-186
test_float.py
Lib/test/test_float.py
+1
-1
test_marshal.py
Lib/test/test_marshal.py
+6
-6
test_posixpath.py
Lib/test/test_posixpath.py
+2
-2
No files found.
Lib/bsddb/test/test_compare.py
Dosyayı görüntüle @
5d36a55e
...
@@ -9,207 +9,207 @@ import unittest
...
@@ -9,207 +9,207 @@ import unittest
from
bsddb3
import
db
from
bsddb3
import
db
def
lexical_cmp
(
db
,
left
,
right
):
def
lexical_cmp
(
db
,
left
,
right
):
return
cmp
(
left
,
right
)
return
cmp
(
left
,
right
)
def
lowercase_cmp
(
db
,
left
,
right
):
def
lowercase_cmp
(
db
,
left
,
right
):
return
cmp
(
left
.
lower
(),
right
.
lower
())
return
cmp
(
left
.
lower
(),
right
.
lower
())
def
make_reverse_comparator
(
cmp
):
def
make_reverse_comparator
(
cmp
):
def
reverse
(
db
,
left
,
right
,
delegate
=
cmp
):
def
reverse
(
db
,
left
,
right
,
delegate
=
cmp
):
return
-
delegate
(
db
,
left
,
right
)
return
-
delegate
(
db
,
left
,
right
)
return
reverse
return
reverse
_expected_lexical_test_data
=
[
''
,
'CCCP'
,
'a'
,
'aaa'
,
'b'
,
'c'
,
'cccce'
,
'ccccf'
]
_expected_lexical_test_data
=
[
''
,
'CCCP'
,
'a'
,
'aaa'
,
'b'
,
'c'
,
'cccce'
,
'ccccf'
]
_expected_lowercase_test_data
=
[
''
,
'a'
,
'aaa'
,
'b'
,
'c'
,
'CC'
,
'cccce'
,
'ccccf'
,
'CCCP'
]
_expected_lowercase_test_data
=
[
''
,
'a'
,
'aaa'
,
'b'
,
'c'
,
'CC'
,
'cccce'
,
'ccccf'
,
'CCCP'
]
class
ComparatorTests
(
unittest
.
TestCase
):
class
ComparatorTests
(
unittest
.
TestCase
):
def
comparator_test_helper
(
self
,
comparator
,
expected_data
):
def
comparator_test_helper
(
self
,
comparator
,
expected_data
):
data
=
expected_data
[:]
data
=
expected_data
[:]
data
.
sort
(
lambda
l
,
r
,
cmp
=
comparator
:
cmp
(
None
,
l
,
r
))
data
.
sort
(
lambda
l
,
r
,
cmp
=
comparator
:
cmp
(
None
,
l
,
r
))
self
.
failUnless
(
data
==
expected_data
,
self
.
failUnless
(
data
==
expected_data
,
"comparator `
%
s' is not right:
%
s vs.
%
s"
"comparator `
%
s' is not right:
%
s vs.
%
s"
%
(
comparator
,
expected_data
,
data
))
%
(
comparator
,
expected_data
,
data
))
def
test_lexical_comparator
(
self
):
def
test_lexical_comparator
(
self
):
self
.
comparator_test_helper
(
lexical_cmp
,
_expected_lexical_test_data
)
self
.
comparator_test_helper
(
lexical_cmp
,
_expected_lexical_test_data
)
def
test_reverse_lexical_comparator
(
self
):
def
test_reverse_lexical_comparator
(
self
):
rev
=
_expected_lexical_test_data
[:]
rev
=
_expected_lexical_test_data
[:]
rev
.
reverse
()
rev
.
reverse
()
self
.
comparator_test_helper
(
make_reverse_comparator
(
lexical_cmp
),
self
.
comparator_test_helper
(
make_reverse_comparator
(
lexical_cmp
),
rev
)
rev
)
def
test_lowercase_comparator
(
self
):
def
test_lowercase_comparator
(
self
):
self
.
comparator_test_helper
(
lowercase_cmp
,
self
.
comparator_test_helper
(
lowercase_cmp
,
_expected_lowercase_test_data
)
_expected_lowercase_test_data
)
class
AbstractBtreeKeyCompareTestCase
(
unittest
.
TestCase
):
class
AbstractBtreeKeyCompareTestCase
(
unittest
.
TestCase
):
env
=
None
env
=
None
db
=
None
db
=
None
def
setUp
(
self
):
def
setUp
(
self
):
self
.
filename
=
self
.
__class__
.
__name__
+
'.db'
self
.
filename
=
self
.
__class__
.
__name__
+
'.db'
homeDir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
sys
.
argv
[
0
]),
'db_home'
)
homeDir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
sys
.
argv
[
0
]),
'db_home'
)
self
.
homeDir
=
homeDir
self
.
homeDir
=
homeDir
try
:
try
:
os
.
mkdir
(
homeDir
)
os
.
mkdir
(
homeDir
)
except
os
.
error
:
except
os
.
error
:
pass
pass
env
=
db
.
DBEnv
()
env
=
db
.
DBEnv
()
env
.
open
(
homeDir
,
env
.
open
(
homeDir
,
db
.
DB_CREATE
|
db
.
DB_INIT_MPOOL
db
.
DB_CREATE
|
db
.
DB_INIT_MPOOL
|
db
.
DB_INIT_LOCK
|
db
.
DB_THREAD
)
|
db
.
DB_INIT_LOCK
|
db
.
DB_THREAD
)
self
.
env
=
env
self
.
env
=
env
def
tearDown
(
self
):
def
tearDown
(
self
):
self
.
closeDB
()
self
.
closeDB
()
if
self
.
env
is
not
None
:
if
self
.
env
is
not
None
:
self
.
env
.
close
()
self
.
env
.
close
()
self
.
env
=
None
self
.
env
=
None
import
glob
import
glob
map
(
os
.
remove
,
glob
.
glob
(
os
.
path
.
join
(
self
.
homeDir
,
'*'
)))
map
(
os
.
remove
,
glob
.
glob
(
os
.
path
.
join
(
self
.
homeDir
,
'*'
)))
def
addDataToDB
(
self
,
data
):
def
addDataToDB
(
self
,
data
):
i
=
0
i
=
0
for
item
in
data
:
for
item
in
data
:
self
.
db
.
put
(
item
,
str
(
i
))
self
.
db
.
put
(
item
,
str
(
i
))
i
=
i
+
1
i
=
i
+
1
def
createDB
(
self
,
key_comparator
):
def
createDB
(
self
,
key_comparator
):
self
.
db
=
db
.
DB
(
self
.
env
)
self
.
db
=
db
.
DB
(
self
.
env
)
self
.
setupDB
(
key_comparator
)
self
.
setupDB
(
key_comparator
)
self
.
db
.
open
(
self
.
filename
,
"test"
,
db
.
DB_BTREE
,
db
.
DB_CREATE
)
self
.
db
.
open
(
self
.
filename
,
"test"
,
db
.
DB_BTREE
,
db
.
DB_CREATE
)
def
setupDB
(
self
,
key_comparator
):
def
setupDB
(
self
,
key_comparator
):
self
.
db
.
set_bt_compare
(
key_comparator
)
self
.
db
.
set_bt_compare
(
key_comparator
)
def
closeDB
(
self
):
def
closeDB
(
self
):
if
self
.
db
is
not
None
:
if
self
.
db
is
not
None
:
self
.
db
.
close
()
self
.
db
.
close
()
self
.
db
=
None
self
.
db
=
None
def
startTest
(
self
):
def
startTest
(
self
):
pass
pass
def
finishTest
(
self
,
expected
=
None
):
def
finishTest
(
self
,
expected
=
None
):
if
expected
is
not
None
:
if
expected
is
not
None
:
self
.
check_results
(
expected
)
self
.
check_results
(
expected
)
self
.
closeDB
()
self
.
closeDB
()
def
check_results
(
self
,
expected
):
def
check_results
(
self
,
expected
):
curs
=
self
.
db
.
cursor
()
curs
=
self
.
db
.
cursor
()
try
:
try
:
index
=
0
index
=
0
rec
=
curs
.
first
()
rec
=
curs
.
first
()
while
rec
:
while
rec
:
key
,
ignore
=
rec
key
,
ignore
=
rec
self
.
failUnless
(
index
<
len
(
expected
),
self
.
failUnless
(
index
<
len
(
expected
),
"to many values returned from cursor"
)
"to many values returned from cursor"
)
self
.
failUnless
(
expected
[
index
]
==
key
,
self
.
failUnless
(
expected
[
index
]
==
key
,
"expected value `
%
s' at
%
d but got `
%
s'"
"expected value `
%
s' at
%
d but got `
%
s'"
%
(
expected
[
index
],
index
,
key
))
%
(
expected
[
index
],
index
,
key
))
index
=
index
+
1
index
=
index
+
1
rec
=
curs
.
next
()
rec
=
curs
.
next
()
self
.
failUnless
(
index
==
len
(
expected
),
self
.
failUnless
(
index
==
len
(
expected
),
"not enough values returned from cursor"
)
"not enough values returned from cursor"
)
finally
:
finally
:
curs
.
close
()
curs
.
close
()
class
BtreeKeyCompareTestCase
(
AbstractBtreeKeyCompareTestCase
):
class
BtreeKeyCompareTestCase
(
AbstractBtreeKeyCompareTestCase
):
def
runCompareTest
(
self
,
comparator
,
data
):
def
runCompareTest
(
self
,
comparator
,
data
):
self
.
startTest
()
self
.
startTest
()
self
.
createDB
(
comparator
)
self
.
createDB
(
comparator
)
self
.
addDataToDB
(
data
)
self
.
addDataToDB
(
data
)
self
.
finishTest
(
data
)
self
.
finishTest
(
data
)
def
test_lexical_ordering
(
self
):
def
test_lexical_ordering
(
self
):
self
.
runCompareTest
(
lexical_cmp
,
_expected_lexical_test_data
)
self
.
runCompareTest
(
lexical_cmp
,
_expected_lexical_test_data
)
def
test_reverse_lexical_ordering
(
self
):
def
test_reverse_lexical_ordering
(
self
):
expected_rev_data
=
_expected_lexical_test_data
[:]
expected_rev_data
=
_expected_lexical_test_data
[:]
expected_rev_data
.
reverse
()
expected_rev_data
.
reverse
()
self
.
runCompareTest
(
make_reverse_comparator
(
lexical_cmp
),
self
.
runCompareTest
(
make_reverse_comparator
(
lexical_cmp
),
expected_rev_data
)
expected_rev_data
)
def
test_compare_function_useless
(
self
):
def
test_compare_function_useless
(
self
):
self
.
startTest
()
self
.
startTest
()
def
socialist_comparator
(
db
,
l
,
r
):
def
socialist_comparator
(
db
,
l
,
r
):
return
0
return
0
self
.
createDB
(
socialist_comparator
)
self
.
createDB
(
socialist_comparator
)
self
.
addDataToDB
([
'b'
,
'a'
,
'd'
])
self
.
addDataToDB
([
'b'
,
'a'
,
'd'
])
# all things being equal the first key will be the only key
# all things being equal the first key will be the only key
# in the database... (with the last key's value fwiw)
# in the database... (with the last key's value fwiw)
self
.
finishTest
([
'b'
])
self
.
finishTest
([
'b'
])
class
BtreeExceptionsTestCase
(
AbstractBtreeKeyCompareTestCase
):
class
BtreeExceptionsTestCase
(
AbstractBtreeKeyCompareTestCase
):
def
test_raises_non_callable
(
self
):
def
test_raises_non_callable
(
self
):
self
.
startTest
()
self
.
startTest
()
self
.
assertRaises
(
TypeError
,
self
.
createDB
,
'abc'
)
self
.
assertRaises
(
TypeError
,
self
.
createDB
,
'abc'
)
self
.
assertRaises
(
TypeError
,
self
.
createDB
,
None
)
self
.
assertRaises
(
TypeError
,
self
.
createDB
,
None
)
self
.
finishTest
()
self
.
finishTest
()
def
test_set_bt_compare_with_function
(
self
):
def
test_set_bt_compare_with_function
(
self
):
self
.
startTest
()
self
.
startTest
()
self
.
createDB
(
lexical_cmp
)
self
.
createDB
(
lexical_cmp
)
self
.
finishTest
()
self
.
finishTest
()
def
check_results
(
self
,
results
):
def
check_results
(
self
,
results
):
pass
pass
def
test_compare_function_incorrect
(
self
):
def
test_compare_function_incorrect
(
self
):
self
.
startTest
()
self
.
startTest
()
def
bad_comparator
(
db
,
l
,
r
):
def
bad_comparator
(
db
,
l
,
r
):
return
1
return
1
# verify that set_bt_compare checks that comparator(db, '', '') == 0
# verify that set_bt_compare checks that comparator(db, '', '') == 0
self
.
assertRaises
(
TypeError
,
self
.
createDB
,
bad_comparator
)
self
.
assertRaises
(
TypeError
,
self
.
createDB
,
bad_comparator
)
self
.
finishTest
()
self
.
finishTest
()
def
test_compare_function_exception
(
self
):
def
test_compare_function_exception
(
self
):
self
.
startTest
()
self
.
startTest
()
def
bad_comparator
(
db
,
l
,
r
):
def
bad_comparator
(
db
,
l
,
r
):
if
l
==
r
:
if
l
==
r
:
# pass the set_bt_compare test
# pass the set_bt_compare test
return
0
return
0
raise
RuntimeError
,
"i'm a naughty comparison function"
raise
RuntimeError
,
"i'm a naughty comparison function"
self
.
createDB
(
bad_comparator
)
self
.
createDB
(
bad_comparator
)
print
"
\n
*** this test should print 2 uncatchable tracebacks ***"
print
"
\n
*** this test should print 2 uncatchable tracebacks ***"
self
.
addDataToDB
([
'a'
,
'b'
,
'c'
])
# this should raise, but...
self
.
addDataToDB
([
'a'
,
'b'
,
'c'
])
# this should raise, but...
self
.
finishTest
()
self
.
finishTest
()
def
test_compare_function_bad_return
(
self
):
def
test_compare_function_bad_return
(
self
):
self
.
startTest
()
self
.
startTest
()
def
bad_comparator
(
db
,
l
,
r
):
def
bad_comparator
(
db
,
l
,
r
):
if
l
==
r
:
if
l
==
r
:
# pass the set_bt_compare test
# pass the set_bt_compare test
return
0
return
0
return
l
return
l
self
.
createDB
(
bad_comparator
)
self
.
createDB
(
bad_comparator
)
print
"
\n
*** this test should print 2 errors about returning an int ***"
print
"
\n
*** this test should print 2 errors about returning an int ***"
self
.
addDataToDB
([
'a'
,
'b'
,
'c'
])
# this should raise, but...
self
.
addDataToDB
([
'a'
,
'b'
,
'c'
])
# this should raise, but...
self
.
finishTest
()
self
.
finishTest
()
def
test_cannot_assign_twice
(
self
):
def
test_cannot_assign_twice
(
self
):
def
my_compare
(
db
,
a
,
b
):
def
my_compare
(
db
,
a
,
b
):
return
0
return
0
self
.
startTest
()
self
.
startTest
()
self
.
createDB
(
my_compare
)
self
.
createDB
(
my_compare
)
try
:
try
:
self
.
db
.
set_bt_compare
(
my_compare
)
self
.
db
.
set_bt_compare
(
my_compare
)
assert
False
,
"this set should fail"
assert
False
,
"this set should fail"
except
RuntimeError
,
msg
:
except
RuntimeError
,
msg
:
pass
pass
def
test_suite
():
def
test_suite
():
res
=
unittest
.
TestSuite
()
res
=
unittest
.
TestSuite
()
res
.
addTest
(
unittest
.
makeSuite
(
ComparatorTests
))
res
.
addTest
(
unittest
.
makeSuite
(
ComparatorTests
))
if
db
.
version
()
>=
(
3
,
3
,
11
):
if
db
.
version
()
>=
(
3
,
3
,
11
):
res
.
addTest
(
unittest
.
makeSuite
(
BtreeExceptionsTestCase
))
res
.
addTest
(
unittest
.
makeSuite
(
BtreeExceptionsTestCase
))
res
.
addTest
(
unittest
.
makeSuite
(
BtreeKeyCompareTestCase
))
res
.
addTest
(
unittest
.
makeSuite
(
BtreeKeyCompareTestCase
))
return
res
return
res
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
(
defaultTest
=
'suite'
)
unittest
.
main
(
defaultTest
=
'suite'
)
Lib/test/test_float.py
Dosyayı görüntüle @
5d36a55e
...
@@ -58,7 +58,7 @@ class UnknownFormatTestCase(unittest.TestCase):
...
@@ -58,7 +58,7 @@ class UnknownFormatTestCase(unittest.TestCase):
'float'
:
float
.
__getformat__
(
'float'
)}
'float'
:
float
.
__getformat__
(
'float'
)}
float
.
__setformat__
(
'double'
,
'unknown'
)
float
.
__setformat__
(
'double'
,
'unknown'
)
float
.
__setformat__
(
'float'
,
'unknown'
)
float
.
__setformat__
(
'float'
,
'unknown'
)
def
tearDown
(
self
):
def
tearDown
(
self
):
float
.
__setformat__
(
'double'
,
self
.
save_formats
[
'double'
])
float
.
__setformat__
(
'double'
,
self
.
save_formats
[
'double'
])
float
.
__setformat__
(
'float'
,
self
.
save_formats
[
'float'
])
float
.
__setformat__
(
'float'
,
self
.
save_formats
[
'float'
])
...
...
Lib/test/test_marshal.py
Dosyayı görüntüle @
5d36a55e
...
@@ -78,26 +78,26 @@ class FloatTestCase(unittest.TestCase):
...
@@ -78,26 +78,26 @@ class FloatTestCase(unittest.TestCase):
self
.
assertEqual
(
f
,
got
)
self
.
assertEqual
(
f
,
got
)
# and with version <= 1 (floats marshalled differently then)
# and with version <= 1 (floats marshalled differently then)
s
=
marshal
.
dumps
(
f
,
1
)
s
=
marshal
.
dumps
(
f
,
1
)
got
=
marshal
.
loads
(
s
)
got
=
marshal
.
loads
(
s
)
self
.
assertEqual
(
f
,
got
)
self
.
assertEqual
(
f
,
got
)
n
=
sys
.
maxint
*
3.7e-250
n
=
sys
.
maxint
*
3.7e-250
while
n
<
small
:
while
n
<
small
:
for
expected
in
(
-
n
,
n
):
for
expected
in
(
-
n
,
n
):
f
=
float
(
expected
)
f
=
float
(
expected
)
s
=
marshal
.
dumps
(
f
)
s
=
marshal
.
dumps
(
f
)
got
=
marshal
.
loads
(
s
)
got
=
marshal
.
loads
(
s
)
self
.
assertEqual
(
f
,
got
)
self
.
assertEqual
(
f
,
got
)
s
=
marshal
.
dumps
(
f
,
1
)
s
=
marshal
.
dumps
(
f
,
1
)
got
=
marshal
.
loads
(
s
)
got
=
marshal
.
loads
(
s
)
self
.
assertEqual
(
f
,
got
)
self
.
assertEqual
(
f
,
got
)
marshal
.
dump
(
f
,
file
(
test_support
.
TESTFN
,
"wb"
))
marshal
.
dump
(
f
,
file
(
test_support
.
TESTFN
,
"wb"
))
got
=
marshal
.
load
(
file
(
test_support
.
TESTFN
,
"rb"
))
got
=
marshal
.
load
(
file
(
test_support
.
TESTFN
,
"rb"
))
self
.
assertEqual
(
f
,
got
)
self
.
assertEqual
(
f
,
got
)
marshal
.
dump
(
f
,
file
(
test_support
.
TESTFN
,
"wb"
),
1
)
marshal
.
dump
(
f
,
file
(
test_support
.
TESTFN
,
"wb"
),
1
)
got
=
marshal
.
load
(
file
(
test_support
.
TESTFN
,
"rb"
))
got
=
marshal
.
load
(
file
(
test_support
.
TESTFN
,
"rb"
))
self
.
assertEqual
(
f
,
got
)
self
.
assertEqual
(
f
,
got
)
...
...
Lib/test/test_posixpath.py
Dosyayı görüntüle @
5d36a55e
...
@@ -476,7 +476,7 @@ class PosixPathTest(unittest.TestCase):
...
@@ -476,7 +476,7 @@ class PosixPathTest(unittest.TestCase):
self
.
safe_rmdir
(
ABSTFN
+
"/k/y"
)
self
.
safe_rmdir
(
ABSTFN
+
"/k/y"
)
self
.
safe_rmdir
(
ABSTFN
+
"/k"
)
self
.
safe_rmdir
(
ABSTFN
+
"/k"
)
self
.
safe_rmdir
(
ABSTFN
)
self
.
safe_rmdir
(
ABSTFN
)
def
test_realpath_resolve_first
(
self
):
def
test_realpath_resolve_first
(
self
):
# Bug #1213894: The first component of the path, if not absolute,
# Bug #1213894: The first component of the path, if not absolute,
# must be resolved too.
# must be resolved too.
...
@@ -487,7 +487,7 @@ class PosixPathTest(unittest.TestCase):
...
@@ -487,7 +487,7 @@ class PosixPathTest(unittest.TestCase):
os
.
mkdir
(
ABSTFN
+
"/k"
)
os
.
mkdir
(
ABSTFN
+
"/k"
)
os
.
symlink
(
ABSTFN
,
ABSTFN
+
"link"
)
os
.
symlink
(
ABSTFN
,
ABSTFN
+
"link"
)
os
.
chdir
(
dirname
(
ABSTFN
))
os
.
chdir
(
dirname
(
ABSTFN
))
base
=
basename
(
ABSTFN
)
base
=
basename
(
ABSTFN
)
self
.
assertEqual
(
realpath
(
base
+
"link"
),
ABSTFN
)
self
.
assertEqual
(
realpath
(
base
+
"link"
),
ABSTFN
)
self
.
assertEqual
(
realpath
(
base
+
"link/k"
),
ABSTFN
+
"/k"
)
self
.
assertEqual
(
realpath
(
base
+
"link/k"
),
ABSTFN
+
"/k"
)
...
...
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