mirror of
https://github.com/esp8266/Arduino.git
synced 2026-01-06 05:22:30 +03:00
allow reading test environment from python mocks
This allows requesting environment variable values set in the C++ test code, from python mock code. Use case is cross-checking test results against values expected by the host side part of the test.
This commit is contained in:
committed by
Ivan Grokhotkov
parent
8bd26f2ded
commit
1acaa8b8f6
@@ -49,3 +49,12 @@ TEST_CASE("this test also runs successfully", "[bluesmoke]")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE("environment variables can be set and read from python", "[bluesmoke]")
|
||||
{
|
||||
const char* res = getenv("VAR_FROM_PYTHON");
|
||||
REQUIRE(res != NULL);
|
||||
CHECK(strcmp(res, "42") == 0);
|
||||
setenv("VAR_FROM_TEST", "24", 1);
|
||||
}
|
||||
|
||||
|
||||
11
tests/device/libraries/BSTest/test/test.py
Normal file
11
tests/device/libraries/BSTest/test/test.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from mock_decorators import setup, teardown, setenv, request_env
|
||||
|
||||
@setup('environment variables can be set and read from python')
|
||||
def setup_envtest(e):
|
||||
setenv(e, 'VAR_FROM_PYTHON', '42')
|
||||
|
||||
|
||||
@teardown('environment variables can be set and read from python')
|
||||
def teardown_envtest(e):
|
||||
env_value = request_env(e, 'VAR_FROM_TEST')
|
||||
assert(env_value == '24')
|
||||
Reference in New Issue
Block a user