|
2 | 2 | mostly functional tests of gateways. |
3 | 3 | """ |
4 | 4 | import os |
| 5 | +from textwrap import dedent |
| 6 | + |
5 | 7 | import py |
6 | 8 | import pytest |
7 | 9 | import socket |
|
15 | 17 | needs_osdup = py.test.mark.skipif("not hasattr(os, 'dup')") |
16 | 18 |
|
17 | 19 |
|
| 20 | +flakytest = pytest.mark.xfail(reason='on some systems this test fails due to timing problems') |
18 | 21 | skip_win_pypy = pytest.mark.xfail(condition=hasattr(sys, 'pypy_version_info') and sys.platform.startswith('win'), |
19 | 22 | reason='failing on Windows on PyPy (#63)') |
20 | 23 |
|
@@ -76,6 +79,7 @@ def test_gateway_status_no_real_channel(self, gw): |
76 | 79 | # closure of temporary channels |
77 | 80 | assert numchan2 == numchan |
78 | 81 |
|
| 82 | + @flakytest |
79 | 83 | def test_gateway_status_busy(self, gw): |
80 | 84 | numchannels = gw.remote_status().numchannels |
81 | 85 | ch1 = gw.remote_exec("channel.send(1); channel.receive()") |
@@ -110,6 +114,38 @@ def test_remote_exec_module(self, tmpdir, gw): |
110 | 114 | name = channel.receive() |
111 | 115 | assert name == 2 |
112 | 116 |
|
| 117 | + def test_remote_exec_module_with_traceback(self, gw, tmpdir, monkeypatch): |
| 118 | + remotetest = tmpdir.join("remotetest.py") |
| 119 | + remotetest.write(dedent(""" |
| 120 | + def run_me(channel=None): |
| 121 | + raise ValueError('me') |
| 122 | +
|
| 123 | + if __name__ == '__channelexec__': |
| 124 | + run_me() |
| 125 | + """) |
| 126 | + ) |
| 127 | + |
| 128 | + monkeypatch.syspath_prepend(tmpdir) |
| 129 | + import remotetest |
| 130 | + |
| 131 | + ch = gw.remote_exec(remotetest) |
| 132 | + try: |
| 133 | + ch.receive() |
| 134 | + except execnet.gateway_base.RemoteError as e: |
| 135 | + assert 'remotetest.py", line 3, in run_me' in str(e) |
| 136 | + assert "ValueError: me" in str(e) |
| 137 | + finally: |
| 138 | + ch.close() |
| 139 | + |
| 140 | + ch = gw.remote_exec(remotetest.run_me) |
| 141 | + try: |
| 142 | + ch.receive() |
| 143 | + except execnet.gateway_base.RemoteError as e: |
| 144 | + assert 'remotetest.py", line 3, in run_me' in str(e) |
| 145 | + assert "ValueError: me" in str(e) |
| 146 | + finally: |
| 147 | + ch.close() |
| 148 | + |
113 | 149 | def test_correct_setup_no_py(self, gw): |
114 | 150 | channel = gw.remote_exec(""" |
115 | 151 | import sys |
@@ -347,6 +383,7 @@ def test_threads_race_sending(self, makegateway): |
347 | 383 | for ch in channels: |
348 | 384 | ch.waitclose(TESTTIMEOUT) |
349 | 385 |
|
| 386 | + @flakytest |
350 | 387 | def test_status_with_threads(self, makegateway): |
351 | 388 | gw = makegateway('popen') |
352 | 389 | c1 = gw.remote_exec("channel.send(1) ; channel.receive()") |
@@ -391,6 +428,7 @@ def test_popen_filetracing(self, testdir, monkeypatch, makegateway): |
391 | 428 | gw.exit() |
392 | 429 |
|
393 | 430 | @skip_win_pypy |
| 431 | + @flakytest |
394 | 432 | def test_popen_stderr_tracing(self, capfd, monkeypatch, makegateway): |
395 | 433 | monkeypatch.setenv('EXECNET_DEBUG', "2") |
396 | 434 | gw = makegateway("popen") |
|
0 commit comments