debugpy/pytests/func/test_run.py
Pavel Minaev e96275703a
Testing framework for timeline-based tests. (#857)
* Testing framework for timeline-based tests.

See pytests/helpers/timeline.md for a detailed description.

Fixes #832, and lays the groundwork for #833.

* Upgrade pip to most recent version before installing prerequisites on Travis.
2018-10-01 14:29:44 -07:00

39 lines
1.2 KiB
Python

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See LICENSE in the project root
# for license information.
from __future__ import print_function, with_statement, absolute_import
from ..helpers.pattern import ANY
from ..helpers.timeline import Event
def test_run(debug_session, pyfile):
@pyfile
def code_to_debug():
print('waiting for input')
input()
print('got input!')
debug_session.prepare_to_run(filename=code_to_debug)
debug_session.start_debugging()
t = debug_session.wait_until(Event('process') & Event('thread'))
assert (
Event('thread', {'reason': 'started', 'threadId': ANY})
& (
Event('initialized', {})
>>
Event('process', {
'name': code_to_debug,
'isLocalProcess': True,
'startMethod': 'launch' if debug_session.method == 'launch' else 'attach',
'systemProcessId': debug_session.process.pid,
})
)
).has_occurred_by(t)
with debug_session.causing(Event('terminated', {})):
debug_session.process.communicate(b'0\n')
debug_session.wait_for_exit()