Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_openpty.py @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | 228cfb6e2900 |
| children | a7381fe515e8 |
| rev | line source |
|---|---|
|
13269
e72cb42176bc
Thomas Wouters: Test script for openpty()
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 # Test to see if openpty works. (But don't worry if it isn't available.) |
|
e72cb42176bc
Thomas Wouters: Test script for openpty()
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 |
|
40267
75506810cbbf
Convert test_openpty to unittest.
Georg Brandl <georg@python.org>
parents:
26976
diff
changeset
|
3 import os, unittest |
|
52355
228cfb6e2900
fix incorrect auto-translation of TestSkipped -> unittest.SkipTest
Benjamin Peterson <benjamin@python.org>
parents:
52353
diff
changeset
|
4 from test.test_support import run_unittest |
|
40267
75506810cbbf
Convert test_openpty to unittest.
Georg Brandl <georg@python.org>
parents:
26976
diff
changeset
|
5 |
|
40269
0d0ae84dd1b7
Move the check for openpty to the beginning.
Georg Brandl <georg@python.org>
parents:
40267
diff
changeset
|
6 if not hasattr(os, "openpty"): |
|
52355
228cfb6e2900
fix incorrect auto-translation of TestSkipped -> unittest.SkipTest
Benjamin Peterson <benjamin@python.org>
parents:
52353
diff
changeset
|
7 raise unittest.SkipTest, "No openpty() available." |
|
40269
0d0ae84dd1b7
Move the check for openpty to the beginning.
Georg Brandl <georg@python.org>
parents:
40267
diff
changeset
|
8 |
|
0d0ae84dd1b7
Move the check for openpty to the beginning.
Georg Brandl <georg@python.org>
parents:
40267
diff
changeset
|
9 |
|
40267
75506810cbbf
Convert test_openpty to unittest.
Georg Brandl <georg@python.org>
parents:
26976
diff
changeset
|
10 class OpenptyTest(unittest.TestCase): |
|
75506810cbbf
Convert test_openpty to unittest.
Georg Brandl <georg@python.org>
parents:
26976
diff
changeset
|
11 def test(self): |
|
40269
0d0ae84dd1b7
Move the check for openpty to the beginning.
Georg Brandl <georg@python.org>
parents:
40267
diff
changeset
|
12 master, slave = os.openpty() |
|
40267
75506810cbbf
Convert test_openpty to unittest.
Georg Brandl <georg@python.org>
parents:
26976
diff
changeset
|
13 if not os.isatty(slave): |
|
75506810cbbf
Convert test_openpty to unittest.
Georg Brandl <georg@python.org>
parents:
26976
diff
changeset
|
14 self.fail("Slave-end of pty is not a terminal.") |
|
75506810cbbf
Convert test_openpty to unittest.
Georg Brandl <georg@python.org>
parents:
26976
diff
changeset
|
15 |
|
75506810cbbf
Convert test_openpty to unittest.
Georg Brandl <georg@python.org>
parents:
26976
diff
changeset
|
16 os.write(slave, 'Ping!') |
|
75506810cbbf
Convert test_openpty to unittest.
Georg Brandl <georg@python.org>
parents:
26976
diff
changeset
|
17 self.assertEqual(os.read(master, 1024), 'Ping!') |
|
13269
e72cb42176bc
Thomas Wouters: Test script for openpty()
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 |
|
40267
75506810cbbf
Convert test_openpty to unittest.
Georg Brandl <georg@python.org>
parents:
26976
diff
changeset
|
19 def test_main(): |
|
75506810cbbf
Convert test_openpty to unittest.
Georg Brandl <georg@python.org>
parents:
26976
diff
changeset
|
20 run_unittest(OpenptyTest) |
|
13269
e72cb42176bc
Thomas Wouters: Test script for openpty()
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 |
|
40267
75506810cbbf
Convert test_openpty to unittest.
Georg Brandl <georg@python.org>
parents:
26976
diff
changeset
|
22 if __name__ == '__main__': |
|
75506810cbbf
Convert test_openpty to unittest.
Georg Brandl <georg@python.org>
parents:
26976
diff
changeset
|
23 test_main() |
