Pytest Defaulting to local build directory, even when set otherwise
Posted: Tue May 21, 2024 5:54 pm
I'm using Pytest to manage the manufacturing tests for an ESP32S3 product I'm working on. I'm finding that something in the software stack is ignoring the app_path parameter when there is a build directory within the same pytest directory.
Project directory structure
Here's an example test with it's parameters:
I'm running the pytest command from the project root/test_app_system_level/ directory, and for some reason, instead of using the f"{os.path.dirname(os.path.dirname(__file__))}", it just looks in ./build.
I'm seeing this because it gives a wrong chip error, and that error gets cleared up when I delete the project root/test_app_system_level/build directory.
Is there a way to force it to use the directory I'm selecting in app_path?
Project directory structure
Code: Select all
Project root directory
- (main)
- - source code
- (build)
- - main code build files
- (test_app_system_level)
- - (main)
- - - secondary processor source code
- - (build)
- - - secondary processor build files
- - test_app.py
Code: Select all
PARAMS = "count, app_path, port"
PARAMS_VALUES = [
(
1,
f"{os.path.dirname(os.path.dirname(__file__))}",
"/dev/ttyACM0",
),
]
@pytest.mark.parametrize(
PARAMS,
PARAMS_VALUES,
indirect=True,
)
def test_hello_world(dut: IdfDut):
res = dut.expect(r"Hello (\w+)")
logging.info(f'Hello from {res.group(1).decode("utf-8")}')
I'm seeing this because it gives a wrong chip error, and that error gets cleared up when I delete the project root/test_app_system_level/build directory.
Is there a way to force it to use the directory I'm selecting in app_path?