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
4c136eef
Kaydet (Commit)
4c136eef
authored
Haz 30, 2000
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Thomas Wouters <thomas@xs4all.net>:
Test case for the pty module.
üst
276fa43f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
0 deletions
+97
-0
test_pty
Lib/test/output/test_pty
+3
-0
test_pty.py
Lib/test/test_pty.py
+94
-0
No files found.
Lib/test/output/test_pty
0 → 100644
Dosyayı görüntüle @
4c136eef
test_pty
I wish to buy a fish license.
For my pet fish, Eric.
Lib/test/test_pty.py
0 → 100644
Dosyayı görüntüle @
4c136eef
import
pty
,
os
,
sys
,
string
from
test_support
import
verbose
,
TestFailed
TEST_STRING_1
=
"I wish to buy a fish license."
TEST_STRING_2
=
"For my pet fish, Eric."
TEST_STRING_3
=
"And now for something completely different..."
TEST_STRING_4
=
"but you pronounce it throatwobbler mangrove."
if
verbose
:
def
debug
(
msg
):
print
msg
else
:
def
debug
(
msg
):
pass
# Marginal testing of pty suite. Cannot do extensive 'do or fail' testing
# because pty code is not too portable.
try
:
debug
(
"Calling master_open()"
)
master_fd
,
slave_name
=
pty
.
master_open
()
debug
(
"Got master_fd '
%
d', slave_name '
%
s'"
%
(
master_fd
,
slave_name
))
debug
(
"Calling slave_open(
%
s)"
%
`slave_name`
)
slave_fd
=
pty
.
slave_open
(
slave_name
)
debug
(
"Got slave_fd '
%
d'"
%
slave_fd
)
except
OSError
:
# " An optional feature could not be imported " ... ?
raise
ImportError
,
"Pseudo-terminals (seemingly) not functional."
## # Please uncomment these if os.isatty() is added.
## if not os.isatty(master_fd):
## raise TestFailed, "master_fd is not a tty"
## if not os.isatty(slave_fd):
## raise TestFailed, "slave_fd is not a tty"
debug
(
"Writing to slave_fd"
)
os
.
write
(
slave_fd
,
TEST_STRING_1
)
# should check return value
print
os
.
read
(
master_fd
,
1024
)
os
.
write
(
slave_fd
,
TEST_STRING_2
[:
5
])
os
.
write
(
slave_fd
,
TEST_STRING_2
[
5
:])
print
os
.
read
(
master_fd
,
1024
)
os
.
close
(
slave_fd
)
os
.
close
(
master_fd
)
# basic pty passed.
debug
(
"calling pty.fork()"
)
pid
,
master_fd
=
pty
.
fork
()
if
pid
==
pty
.
CHILD
:
## # Please uncomment these when os.isatty() is added.
## if not os.isatty(1):
## debug("Child's fd 1 is not a tty?!")
## os._exit(3)
try
:
debug
(
"In child, calling os.setsid()"
)
os
.
setsid
()
except
OSError
:
# Good, we already were session leader
debug
(
"OSError was raised."
)
pass
except
AttributeError
:
# Have pty, but not setsid() ?
debug
(
"AttributeError was raised."
)
pass
except
:
# We don't want this error to propagate, escape the call to
# os._exit(), and cause very peculiar behaviour in the calling
# regrtest.py !
debug
(
"Some other error was raised."
)
os
.
_exit
(
1
)
else
:
debug
(
"os.setsid() succeeded! (bad!)"
)
os
.
_exit
(
2
)
os
.
_exit
(
4
)
else
:
debug
(
"Waiting for child (
%
d) to finish."
%
pid
)
(
pid
,
status
)
=
os
.
waitpid
(
pid
,
0
)
debug
(
"Child (
%
d) exited with status
%
d."
%
(
pid
,
status
))
if
status
/
256
==
1
:
raise
TestFailed
,
"Child raised an unexpected exception in os.setsid()"
elif
status
/
256
==
2
:
raise
TestFailed
,
"pty.fork() failed to make child a session leader."
elif
status
/
256
==
3
:
raise
TestFailed
,
"Child spawned by pty.fork() did not have a tty as stdout"
elif
status
/
256
<>
4
:
raise
TestFailed
,
"pty.fork() failed for unknown reasons:"
print
os
.
read
(
master_fd
,
65536
)
os
.
close
(
master_fd
)
# pty.fork() passed.
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