Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specify pythonpath for pytest #123

Merged
merged 2 commits into from
Jun 17, 2022
Merged

specify pythonpath for pytest #123

merged 2 commits into from
Jun 17, 2022

Conversation

superlopuh
Copy link
Member

I got import errors due to running on my system version of xdsl as opposed to the local version. Specifying the pythonpath in the config lets pytest choose the correct xdsl. I also added python -m pytest since that's less likely to use a different python version to the one used to install dependencies.

@Dinistro Dinistro requested a review from math-fehr June 17, 2022 11:40
@@ -28,3 +28,4 @@ where = src

[tool:pytest]
python_files = *_test.py test_*.py *_example.py example_*.py
pythonpath = src
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good.

README.md Outdated
@@ -16,7 +16,7 @@ This project includes pytest unit test and llvm-style filecheck tests. They can

```
# Executes pytests which are located in tests/
pytest
python -m pytest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprised this causes a difference. Are you sure this change is needed, and the change below is not sufficient by itself. If both are needed, we should probably change the documentation as suggested here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't necessary but my impression is that it's the recommended best practice. Python versions and tools can go out of sync for reasons that are still unclear to me, and my local pytest was not the same as python -m pytest. This change guarantees that they'll be the same, even if it's a bit more verbose

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a blog post that explains that there are differences, my understanding is that the -m is slightly preferred in this case, but I'm not 100% sure still.
https://blog.ganssle.io/articles/2019/08/test-as-installed.html

Copy link
Contributor

@tobiasgrosser tobiasgrosser Jun 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I then do not have any preference. Happy to merge if you feel -m pytest ir preferable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reading the post, looks like it might be better without the -m, I'll remove this change

Copy link
Collaborator

@math-fehr math-fehr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks a lot!

@math-fehr math-fehr merged commit 828cd3e into xdslproject:main Jun 17, 2022
K-W-Li pushed a commit that referenced this pull request Jun 18, 2022
Specify pythonpath in config file
@webmiche
Copy link
Collaborator

This change causes a warning print in pytest versions < 7.0. We might want to update our requirements to be a version above 7.0.

@superlopuh superlopuh deleted the sasha/pythonpath branch September 21, 2022 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants