mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
examples: Fix Python coding style
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
from __future__ import print_function
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
|
||||
# this is a test case write with tiny-test-fw.
|
||||
# to run test cases outside tiny-test-fw,
|
||||
# we need to set environment variable `TEST_FW_PATH`,
|
||||
# then get and insert `TEST_FW_PATH` to sys path before import FW module
|
||||
test_fw_path = os.getenv('TEST_FW_PATH')
|
||||
if test_fw_path and test_fw_path not in sys.path:
|
||||
sys.path.insert(0, test_fw_path)
|
||||
|
||||
import TinyFW
|
||||
import IDF
|
||||
try:
|
||||
import IDF
|
||||
except ImportError:
|
||||
# this is a test case write with tiny-test-fw.
|
||||
# to run test cases outside tiny-test-fw,
|
||||
# we need to set environment variable `TEST_FW_PATH`,
|
||||
# then get and insert `TEST_FW_PATH` to sys path before import FW module
|
||||
test_fw_path = os.getenv('TEST_FW_PATH')
|
||||
if test_fw_path and test_fw_path not in sys.path:
|
||||
sys.path.insert(0, test_fw_path)
|
||||
import IDF
|
||||
|
||||
# Timer events
|
||||
TIMER_EVENT_LIMIT = 3
|
||||
@@ -26,6 +26,7 @@ TASK_UNREGISTRATION_LIMIT = 3
|
||||
TASK_ITERATION_POST = "TASK_EVENTS:TASK_ITERATION_EVENT: posting to default loop, {} out of " + str(TASK_ITERATION_LIMIT)
|
||||
TASK_ITERATION_HANDLING = "TASK_EVENTS:TASK_ITERATION_EVENT: task_iteration_handler, executed {} times"
|
||||
|
||||
|
||||
def _test_timer_events(dut):
|
||||
dut.start_app()
|
||||
|
||||
@@ -49,13 +50,13 @@ def _test_timer_events(dut):
|
||||
|
||||
if expiries < TIMER_EVENT_LIMIT:
|
||||
dut.expect_all("TIMER_EVENTS:TIMER_EVENT_EXPIRY: all_event_handler",
|
||||
"TIMER_EVENTS:TIMER_EVENT_EXPIRY: timer_any_handler",
|
||||
TIMER_EXPIRY_HANDLING.format(expiries))
|
||||
"TIMER_EVENTS:TIMER_EVENT_EXPIRY: timer_any_handler",
|
||||
TIMER_EXPIRY_HANDLING.format(expiries))
|
||||
else:
|
||||
dut.expect_all("TIMER_EVENTS:TIMER_EVENT_STOPPED: posting to default loop",
|
||||
"TIMER_EVENTS:TIMER_EVENT_EXPIRY: all_event_handler",
|
||||
"TIMER_EVENTS:TIMER_EVENT_EXPIRY: timer_any_handler",
|
||||
TIMER_EXPIRY_HANDLING.format(expiries))
|
||||
"TIMER_EVENTS:TIMER_EVENT_EXPIRY: all_event_handler",
|
||||
"TIMER_EVENTS:TIMER_EVENT_EXPIRY: timer_any_handler",
|
||||
TIMER_EXPIRY_HANDLING.format(expiries))
|
||||
print("Posted timer stopped event")
|
||||
|
||||
print("Handled timer expiry event {} out of {}".format(expiries, TIMER_EVENT_LIMIT))
|
||||
@@ -64,6 +65,7 @@ def _test_timer_events(dut):
|
||||
dut.expect("TIMER_EVENTS:TIMER_EVENT_STOPPED: deleted timer event source")
|
||||
print("Handled timer stopped event")
|
||||
|
||||
|
||||
def _test_iteration_events(dut):
|
||||
dut.start_app()
|
||||
|
||||
@@ -89,6 +91,7 @@ def _test_iteration_events(dut):
|
||||
dut.expect("TASK_EVENTS:TASK_ITERATION_EVENT: deleting task event source")
|
||||
print("Deleted task event source")
|
||||
|
||||
|
||||
@IDF.idf_example_test(env_tag='Example_WIFI')
|
||||
def test_default_event_loop_example(env, extra_data):
|
||||
dut = env.get_dut('default_event_loop', 'examples/system/event/default_event_loop')
|
||||
@@ -96,5 +99,6 @@ def test_default_event_loop_example(env, extra_data):
|
||||
_test_iteration_events(dut)
|
||||
_test_timer_events(dut)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_default_event_loop_example()
|
||||
|
Reference in New Issue
Block a user