Skip to content

Python import path / working-directory issue in conftest.py in py_test ?-> maybe GitHub check do not complete due to this #1454

@FloorBroekgaarden

Description

@FloorBroekgaarden

Describe the bug
pr-1368 and a few earlier PRs around the Cosmic Integration seems to have changed the py_test/conftest.py file in some way that it now seems to have an issue with the Python import path / working-directory issue in conftest.py?

There's also a double / copy of the same line:
`# Testvalues used in test_total_mass_evolved_per_z defined in py_tests/test_values.py
from py_tests.test_values import MAKE_PLOTS, M1_MIN, M1_MAX, M2_MIN, F_BIN

Testvalues used in test_total_mass_evolved_per_z defined in py_tests/test_values.py

from py_tests.test_values import MAKE_PLOTS, M1_MIN, M1_MAX, M2_MIN, F_BIN`

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://github.com/TeamCOMPAS/COMPAS/blob/dev/py_tests/conftest.py
  2. see changes since 4ea8b9e
  3. see error in https://github.com/TeamCOMPAS/COMPAS/actions/runs/22083882124/job/63814365416?pr=1448

Specifically, this and earlier changes does from py_tests.test_values import ...
But I think that in the GitHub Actions job, Python’s sys.path doesn’t include the directory that contains py_tests/, so import py_tests fails.

@jeffriley or others might know best how to fix this neatly (and whether it needs to be fixed?)
maybe something like adding

ROOT = Path(__file__).resolve().parents[1]  # directory that contains py_tests/
sys.path.insert(0, str(ROOT))

from py_tests.test_values import MAKE_PLOTS, M1_MIN, M1_MAX, M2_MIN, F_BIN

but not sure, as the pytest suite seemed to be working before, so it might be something different.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededquestionFurther information is requested

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions