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
5539c783
Kaydet (Commit)
5539c783
authored
Ock 19, 2009
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
make bad file descriptor tests more robust
üst
c84ebe73
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
15 deletions
+32
-15
test_fileio.py
Lib/test/test_fileio.py
+3
-2
test_os.py
Lib/test/test_os.py
+17
-13
test_support.py
Lib/test/test_support.py
+12
-0
No files found.
Lib/test/test_fileio.py
Dosyayı görüntüle @
5539c783
...
...
@@ -7,7 +7,8 @@ import unittest
from
array
import
array
from
weakref
import
proxy
from
test.test_support
import
TESTFN
,
findfile
,
check_warnings
,
run_unittest
from
test.test_support
import
(
TESTFN
,
findfile
,
check_warnings
,
run_unittest
,
make_bad_fd
)
from
UserList
import
UserList
import
_fileio
...
...
@@ -178,7 +179,7 @@ class OtherFileTests(unittest.TestCase):
def
testInvalidFd
(
self
):
self
.
assertRaises
(
ValueError
,
_fileio
.
_FileIO
,
-
10
)
self
.
assertRaises
(
OSError
,
_fileio
.
_FileIO
,
10
)
self
.
assertRaises
(
OSError
,
_fileio
.
_FileIO
,
make_bad_fd
()
)
def
testBadModeArgument
(
self
):
# verify that we get a sensible error message for bad mode argument
...
...
Lib/test/test_os.py
Dosyayı görüntüle @
5539c783
...
...
@@ -540,55 +540,59 @@ class TestInvalidFD(unittest.TestCase):
#We omit close because it doesn'r raise an exception on some platforms
def
get_single
(
f
):
def
helper
(
self
):
if
getattr
(
os
,
f
,
None
):
self
.
assertRaises
(
OSError
,
getattr
(
os
,
f
),
10
)
if
hasattr
(
os
,
f
):
self
.
check
(
getattr
(
os
,
f
)
)
return
helper
for
f
in
singles
:
locals
()[
"test_"
+
f
]
=
get_single
(
f
)
def
check
(
self
,
f
,
*
args
):
self
.
assertRaises
(
OSError
,
f
,
test_support
.
make_bad_fd
(),
*
args
)
def
test_isatty
(
self
):
if
hasattr
(
os
,
"isatty"
):
self
.
assertEqual
(
os
.
isatty
(
10
),
False
)
self
.
assertEqual
(
os
.
isatty
(
test_support
.
make_bad_fd
()
),
False
)
def
test_closerange
(
self
):
if
hasattr
(
os
,
"closerange"
):
self
.
assertEqual
(
os
.
closerange
(
10
,
20
),
None
)
fd
=
test_support
.
make_bad_fd
()
self
.
assertEqual
(
os
.
closerange
(
fd
,
fd
+
10
),
None
)
def
test_dup2
(
self
):
if
hasattr
(
os
,
"dup2"
):
self
.
assertRaises
(
OSError
,
os
.
dup2
,
10
,
20
)
self
.
check
(
os
.
dup2
,
20
)
def
test_fchmod
(
self
):
if
hasattr
(
os
,
"fchmod"
):
self
.
assertRaises
(
OSError
,
os
.
fchmod
,
10
,
0
)
self
.
check
(
os
.
fchmod
,
0
)
def
test_fchown
(
self
):
if
hasattr
(
os
,
"fchown"
):
self
.
assertRaises
(
OSError
,
os
.
fchown
,
10
,
-
1
,
-
1
)
self
.
check
(
os
.
fchown
,
-
1
,
-
1
)
def
test_fpathconf
(
self
):
if
hasattr
(
os
,
"fpathconf"
):
self
.
assertRaises
(
OSError
,
os
.
fpathconf
,
10
,
"PC_NAME_MAX"
)
self
.
check
(
os
.
fpathconf
,
"PC_NAME_MAX"
)
def
test_ftruncate
(
self
):
if
hasattr
(
os
,
"ftruncate"
):
self
.
assertRaises
(
OSError
,
os
.
ftruncate
,
10
,
0
)
self
.
check
(
os
.
ftruncate
,
0
)
def
test_lseek
(
self
):
if
hasattr
(
os
,
"lseek"
):
self
.
assertRaises
(
OSError
,
os
.
lseek
,
10
,
0
,
0
)
self
.
check
(
os
.
lseek
,
0
,
0
)
def
test_read
(
self
):
if
hasattr
(
os
,
"read"
):
self
.
assertRaises
(
OSError
,
os
.
read
,
10
,
1
)
self
.
check
(
os
.
read
,
1
)
def
test_tcsetpgrpt
(
self
):
if
hasattr
(
os
,
"tcsetpgrp"
):
self
.
assertRaises
(
OSError
,
os
.
tcsetpgrp
,
10
,
0
)
self
.
check
(
os
.
tcsetpgrp
,
0
)
def
test_write
(
self
):
if
hasattr
(
os
,
"write"
):
self
.
assertRaises
(
OSError
,
os
.
write
,
10
,
" "
)
self
.
check
(
os
.
write
,
" "
)
if
sys
.
platform
!=
'win32'
:
class
Win32ErrorTests
(
unittest
.
TestCase
):
...
...
Lib/test/test_support.py
Dosyayı görüntüle @
5539c783
...
...
@@ -357,6 +357,18 @@ def sortdict(dict):
withcommas
=
", "
.
join
(
reprpairs
)
return
"{
%
s}"
%
withcommas
def
make_bad_fd
():
"""
Create an invalid file descriptor by opening and closing a file and return
its fd.
"""
file
=
open
(
TESTFN
,
"wb"
)
try
:
return
file
.
fileno
()
finally
:
file
.
close
()
unlink
(
TESTFN
)
def
check_syntax_error
(
testcase
,
statement
):
try
:
compile
(
statement
,
'<test string>'
,
'exec'
)
...
...
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