Skip to content

Commit

Permalink
test(wokwi): add esp32 test case
Browse files Browse the repository at this point in the history
  • Loading branch information
urish committed Oct 24, 2023
1 parent c19632f commit 64a1d26
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions pytest-embedded-wokwi/tests/test_wokwi.py
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)

0 comments on commit 64a1d26

Please sign in to comment.