Skip to content

Commit 6da991f

Browse files
committed
[stream-refactor] Py3.x test fixes
1 parent 14f8f00 commit 6da991f

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

tests/data/stubs/stub-su.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
# #363: old input loop would fail to spot auth failure because of scheduling
1010
# vs. su calling write() twice.
1111
if 'DO_SLOW_AUTH_FAILURE' in os.environ:
12-
os.write(2, 'su: ')
12+
os.write(2, u'su: '.encode())
1313
time.sleep(0.5)
14-
os.write(2, 'incorrect password\n')
14+
os.write(2, u'incorrect password\n'.encode())
1515
os._exit(1)
1616

1717

tests/first_stage_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_valid_syntax(self):
4141
stdout, stderr = proc.communicate()
4242
self.assertEquals(0, proc.returncode)
4343
self.assertEquals(stdout,
44-
mitogen.parent.BootstrapProtocol.EC0_MARKER+'\n')
44+
mitogen.parent.BootstrapProtocol.EC0_MARKER+b('\n'))
4545
self.assertIn(b("Error -5 while decompressing data"), stderr)
4646
finally:
4747
fp.close()

tests/parent_test.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414

1515
import mitogen.parent
1616

17+
try:
18+
file
19+
except NameError:
20+
from io import FileIO as file
21+
1722

1823
def wait_for_child(pid, timeout=1.0):
1924
deadline = time.time() + timeout
@@ -226,7 +231,8 @@ def test_dev_tty_open_succeeds(self):
226231
])
227232
deadline = time.time() + 5.0
228233
mitogen.core.set_block(proc.stdin.fileno())
229-
self.assertEquals(mitogen.core.b('hi\n'), proc.stdin.read())
234+
# read(3) below due to https://bugs.python.org/issue37696
235+
self.assertEquals(mitogen.core.b('hi\n'), proc.stdin.read(3))
230236
waited_pid, status = os.waitpid(proc.pid, 0)
231237
self.assertEquals(proc.pid, waited_pid)
232238
self.assertEquals(0, status)

0 commit comments

Comments
 (0)