I am trying to get pytest working on a project I am working on. I've been struggling to find the correct way to import modules into the tests. For example, I have a test_changelog.py
file that imports release_all_in_one.changelog_utils
but a function in that module calls a function in a different module, jira_utils.py
and its failing to find that.
I have tried many different setups of how to setup tests with pytest. I tried using setup.py, different folder locations etc, but I've landed on having the tests in the same directory as the package, as seen in the tree structure. For reference, testing_utils.py
imports release_all_in_one.utils
and that works fine. I am running it with python -m pytest
.
company_release/
├── release_all_in_one
│ ├── changelog_utils.py
│ ├── confluence_email.py
│ ├── confluence_utils.py
│ ├── create_confluence_page.py
│ ├── __init__.py
│ ├── jira_utils.py
│ ├── parse_confluence.py
│ ├── release_all_in_one_openshift.py
│ ├── release_all_in_one.py
│ ├── tag_branch.py
│ ├── templates
│ │ ├── admin_package_template
│ │ ├── base_template
│ │ ├── cdn_package_template
│ │ ├── fe_package_template
│ │ ├── oddjob_package_template
│ │ ├── openshift_template
│ │ └── procedure.json
│ ├── testing.py
│ └── utils.py
├── setup.py
├── seutp.cfg
└── tests
├── test_changelog.py
├── testing_utils.py
└── test_utils.py
I would love some advice on how these are supposed to imported correctly. I've read over a lot of documentation with no luck.
Aucun commentaire:
Enregistrer un commentaire