Skip to content

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

Merged
iamdefinitelyahuman merged 1 commit intomasterfrom
test-project-flag
Mar 18, 2021
Merged

Flag to run tests against project outside of current working directory#996
iamdefinitelyahuman merged 1 commit intomasterfrom
test-project-flag

Conversation

@iamdefinitelyahuman
Copy link
Copy Markdown
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.

Copy link
Copy Markdown

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
Copy Markdown
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!

Copy link
Copy Markdown

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

@iamdefinitelyahuman iamdefinitelyahuman merged commit 44beb58 into master Mar 18, 2021
@iamdefinitelyahuman iamdefinitelyahuman deleted the test-project-flag branch March 18, 2021 13:37
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