Skip to content

fre make tests use getcwd #738

@laurenchilutti

Description

@laurenchilutti

Describe the bug
Pytest is flexible enough to run inside of subdirectories and automatically launch files with the name test_*.py and *_test.py in the current directory and any subdirectories. If I try to do a pytest in fre/make tests fail due to the use of getcwd. The tests run fine when cwd is the location of fre-cli.

currPath=os.getcwd()
SERIAL_TEST_PATH=f"{currPath}/fre/make/tests/compilation/serial_build"
MULTIJOB_TEST_PATH=f"{currPath}/fre/make/tests/compilation/multijob_build"
CONTAINER_BUILD_TEST_PATH=f"{currPath}/fre/make/tests/compilation/container"
Path(SERIAL_TEST_PATH).mkdir(parents=True,exist_ok=True)
Path(MULTIJOB_TEST_PATH).mkdir(parents=True,exist_ok=True)
Path(CONTAINER_BUILD_TEST_PATH).mkdir(parents=True,exist_ok=True)

To Reproduce
cd fre/make
pytest
a bunch of tests fail due to not finding the yaml file

Expected behavior
the filepath's should be relative to the python script and not the current working directory:

currPath=os.path.dirname(__file__)
SERIAL_TEST_PATH=f"{currPath}/serial_build"
MULTIJOB_TEST_PATH=f"{currPath}/multijob_build"
CONTAINER_BUILD_TEST_PATH=f"{currPath}/container"

and any relative file paths should be defined relative to the location of the test file.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions