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
fcf4435a
Kaydet (Commit)
fcf4435a
authored
Kas 27, 2005
tarafından
Neal Norwitz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Improve test coverage. Hope the test_file changes work the same on windows.
üst
307021f4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
0 deletions
+75
-0
test_builtin.py
Lib/test/test_builtin.py
+13
-0
test_file.py
Lib/test/test_file.py
+33
-0
test_generators.py
Lib/test/test_generators.py
+5
-0
test_set.py
Lib/test/test_set.py
+12
-0
test_syntax.py
Lib/test/test_syntax.py
+12
-0
No files found.
Lib/test/test_builtin.py
Dosyayı görüntüle @
fcf4435a
...
...
@@ -238,8 +238,11 @@ class BuiltinTest(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
compile
)
self
.
assertRaises
(
ValueError
,
compile
,
'print 42
\n
'
,
'<string>'
,
'badmode'
)
self
.
assertRaises
(
ValueError
,
compile
,
'print 42
\n
'
,
'<string>'
,
'single'
,
0xff
)
self
.
assertRaises
(
TypeError
,
compile
,
chr
(
0
),
'f'
,
'exec'
)
if
have_unicode
:
compile
(
unicode
(
'print u"
\xc3\xa5
"
\n
'
,
'utf8'
),
''
,
'exec'
)
self
.
assertRaises
(
TypeError
,
compile
,
unichr
(
0
),
'f'
,
'exec'
)
self
.
assertRaises
(
ValueError
,
compile
,
unicode
(
'a = 1'
),
'f'
,
'bad'
)
def
test_delattr
(
self
):
import
sys
...
...
@@ -421,6 +424,7 @@ class BuiltinTest(unittest.TestCase):
unlink
(
TESTFN
)
self
.
assertRaises
(
TypeError
,
execfile
)
self
.
assertRaises
(
TypeError
,
execfile
,
TESTFN
,
{},
())
import
os
self
.
assertRaises
(
IOError
,
execfile
,
os
.
curdir
)
self
.
assertRaises
(
IOError
,
execfile
,
"I_dont_exist"
)
...
...
@@ -1008,6 +1012,9 @@ class BuiltinTest(unittest.TestCase):
def
__getitem__
(
self
,
index
):
raise
ValueError
self
.
assertRaises
(
ValueError
,
map
,
lambda
x
:
x
,
BadSeq
())
def
badfunc
(
x
):
raise
RuntimeError
self
.
assertRaises
(
RuntimeError
,
map
,
badfunc
,
range
(
5
))
def
test_max
(
self
):
self
.
assertEqual
(
max
(
'123123'
),
'3'
)
...
...
@@ -1239,6 +1246,12 @@ class BuiltinTest(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
range
)
self
.
assertRaises
(
TypeError
,
range
,
1
,
2
,
3
,
4
)
self
.
assertRaises
(
ValueError
,
range
,
1
,
2
,
0
)
self
.
assertRaises
(
ValueError
,
range
,
a
,
a
+
1
,
long
(
0
))
class
badzero
(
int
):
def
__cmp__
(
self
,
other
):
raise
RuntimeError
self
.
assertRaises
(
RuntimeError
,
range
,
a
,
a
+
1
,
badzero
(
1
))
# Reject floats when it would require PyLongs to represent.
# (smaller floats still accepted, but deprecated)
...
...
Lib/test/test_file.py
Dosyayı görüntüle @
fcf4435a
...
...
@@ -100,6 +100,39 @@ else:
print
"writelines accepted sequence of non-string objects"
f
.
close
()
try
:
sys
.
stdin
.
seek
(
0
)
except
IOError
:
pass
else
:
print
"should not be able to seek on sys.stdin"
try
:
sys
.
stdin
.
tell
()
except
IOError
:
pass
else
:
print
"should not be able to seek on sys.stdin"
try
:
sys
.
stdin
.
truncate
()
except
IOError
:
pass
else
:
print
"should not be able to truncate on sys.stdin"
# verify repr works
f
=
open
(
TESTFN
)
if
not
repr
(
f
)
.
startswith
(
"<open file '"
+
TESTFN
):
print
"repr(file) failed"
f
.
close
()
# verify repr works for unicode too
f
=
open
(
unicode
(
TESTFN
))
if
not
repr
(
f
)
.
startswith
(
"<open file u'"
+
TESTFN
):
print
"repr(file with unicode name) failed"
f
.
close
()
# verify that we get a sensible error message for bad mode argument
bad_mode
=
"qwerty"
try
:
...
...
Lib/test/test_generators.py
Dosyayı görüntüle @
fcf4435a
...
...
@@ -1589,6 +1589,11 @@ Traceback (most recent call last):
...
ValueError: 7
>>> f().throw("abc") # throw on just-opened generator
Traceback (most recent call last):
...
TypeError: exceptions must be classes, or instances, not str
Now let's try closing a generator:
...
...
Lib/test/test_set.py
Dosyayı görüntüle @
fcf4435a
...
...
@@ -606,6 +606,8 @@ class TestBasicOps(unittest.TestCase):
def
test_iteration
(
self
):
for
v
in
self
.
set
:
self
.
assert_
(
v
in
self
.
values
)
setiter
=
iter
(
self
.
set
)
self
.
assertEqual
(
setiter
.
_length_cue
(),
len
(
self
.
set
))
def
test_pickling
(
self
):
p
=
pickle
.
dumps
(
self
.
set
)
...
...
@@ -693,6 +695,16 @@ class TestExceptionPropagation(unittest.TestCase):
set
(
'abc'
)
set
(
gooditer
())
def
test_changingSizeWhileIterating
(
self
):
s
=
set
([
1
,
2
,
3
])
try
:
for
i
in
s
:
s
.
update
([
4
])
except
RuntimeError
:
pass
else
:
self
.
fail
(
"no exception when changing size during iteration"
)
#==============================================================================
class
TestSetOfSets
(
unittest
.
TestCase
):
...
...
Lib/test/test_syntax.py
Dosyayı görüntüle @
fcf4435a
...
...
@@ -42,6 +42,18 @@ class SyntaxTestCase(unittest.TestCase):
self
.
_check_error
(
source
,
"global"
)
warnings
.
filters
.
pop
(
0
)
def
test_break_outside_loop
(
self
):
self
.
_check_error
(
"break"
,
"outside loop"
)
def
test_delete_deref
(
self
):
source
=
re
.
sub
(
'(?m)^ *:'
,
''
,
"""
\
:def foo(x):
: def bar():
: print x
: del x
:"""
)
self
.
_check_error
(
source
,
"nested scope"
)
def
test_main
():
test_support
.
run_unittest
(
SyntaxTestCase
)
...
...
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