Skip to content

Commit

Permalink
logs to debug on windows without a VM
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
  • Loading branch information
ivanpauno committed Oct 29, 2021
1 parent 5bd6f32 commit af0c896
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions launch_pytest/launch_pytest/fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,26 @@ def get_event_loop_fixture(*, scope='function', overridable=True):
@pytest.fixture(scope=scope)
def event_loop():
"""Create an event loop instance for each test case."""
import sys
import traceback
loop = asyncio.get_event_loop_policy().new_event_loop()
policy = asyncio.get_event_loop_policy()
try:
old_loop = policy.get_event_loop()
if old_loop is not loop:
old_loop.close()
print('bye event loop 2', file=sys.stderr)
traceback.print_stack()
except RuntimeError:
# Swallow this, since it's probably bad event loop hygiene.
pass
policy.set_event_loop(loop)
print('new event loop', file=sys.stderr)
yield loop
loop.close()
asyncio.set_event_loop_policy(None)
print('bye event loop 1', file=sys.stderr)
traceback.print_stack()
if overridable:
event_loop._launch_pytest_overridable_fixture = True
event_loop._launch_pytest_fixture_scope = scope
Expand Down
4 changes: 4 additions & 0 deletions launch_pytest/test/launch_pytest/tools/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
time.sleep(5)
"""

import sys

@pytest.fixture
def dut():
Expand All @@ -39,13 +40,15 @@ def dut():

@launch_pytest.fixture
def launch_description(dut):
print('new launch description', file=sys.stderr)
return launch.LaunchDescription([
dut,
])


@pytest.mark.launch(fixture=launch_description)
async def test_async_process_tools(dut, launch_context):
print('test async', file=sys.stderr)
await tools.wait_for_start(launch_context, dut, timeout=10)
def check_output(output): assert output == 'hello\n'
await tools.wait_for_output(
Expand All @@ -59,6 +62,7 @@ def check_stderr(err): assert err == 'world\n'

@pytest.mark.launch(fixture=launch_description)
def test_sync_process_tools(dut, launch_context):
print('test sync', file=sys.stderr)
tools.wait_for_start_sync(launch_context, dut, timeout=10)
def check_output(output): assert output == 'hello\n'
tools.wait_for_output_sync(
Expand Down

0 comments on commit af0c896

Please sign in to comment.