-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
import shutil | ||
|
||
import pytest | ||
|
||
wokwi_cli_required = pytest.mark.skipif( | ||
shutil.which('wokwi-cli') is None, | ||
reason='Please make sure that `wokwi-cli` is in your PATH env var. ' | ||
+ 'To install: https://docs.wokwi.com/wokwi-ci/getting-started#cli-installation' | ||
) | ||
|
||
wokwi_token_required = pytest.mark.skipif( | ||
os.getenv('WOKWI_CLI_TOKEN') is None, | ||
reason='Please make sure that `WOKWI_CLI_TOKEN` env var is set. Get a token here: https://wokwi.com/dashboard/ci' | ||
) | ||
|
||
|
||
@wokwi_cli_required | ||
@wokwi_token_required | ||
def test_pexpect_by_wokwi_esp32(testdir): | ||
testdir.makepyfile(""" | ||
import pexpect | ||
import pytest | ||
def test_pexpect_by_wokwi(dut): | ||
dut.expect('Hello world!') | ||
dut.expect('Restarting') | ||
with pytest.raises(pexpect.TIMEOUT): | ||
dut.expect('foo bar not found', timeout=1) | ||
""") | ||
|
||
result = testdir.runpytest( | ||
'-s', | ||
'--embedded-services', 'idf,wokwi', | ||
'--app-path', os.path.join(testdir.tmpdir, 'hello_world_esp32'), | ||
) | ||
|
||
result.assert_outcomes(passed=1) |