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

Flag to run tests against project outside of current working directory #996

Merged
merged 1 commit into from
Mar 18, 2021

Conversation

iamdefinitelyahuman
Copy link
Member

What I did

Add a commandline flag --brownie-project to force loading a project outside of the current working directory when using the brownie pytest plugin.

Closes #994

How I did it

Within test/plugin.py, I've added the _get_project_path method to find the current project path. Because the path required prior to pytest_addoption, it must be extracted directly from sys.argv. It's a bit hacky but it solves the issue.

How to verify it

Try it.

@@ -12,9 +13,23 @@
from brownie.utils import color


def _get_project_path() -> Optional[Path]:
if "--brownie-project" not in sys.argv[:-1]:

Choose a reason for hiding this comment

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

Note: This means --brownie-project=abcd won't work, which is also a standard way of passing args. But It's probably good enough.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh true.. that should be easy enough to support as well. Good catch!

Choose a reason for hiding this comment

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

I am wondering, why not just add the flags in pytest_addoption, regardless of whether we are in a project dir or not?
I mean, if the user doesn't want to use brownie, he can just disable the plugin

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.

Allow testing from another working directory
2 participants