-
Notifications
You must be signed in to change notification settings - Fork 3k
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
make sure the current working dir is in the sys.path #484
Conversation
fyi @cpennington |
Your use case is very similar to how I and many others use locust. Unfortunately, I'd be worried about this breaking people's integrations or having unintended side effects depending on where you are running from and if you have modules or packages with the same name across your project. What I'd like to see before this gets merged is some best practices documentation for structuring a non-flat locust project. Trying to standardize project structures and import paths to some extent will make them easier to support in the future. I made #500 to track that separately, but feel free to take a first stab if you're up for it. |
@cgoldberg what do you think about this one? |
Sorry to bump on this one, but is it likely to get merged at all? @justiniso @cgoldberg |
@heyman What is your opinion on this? I agree that it may be a bit disruptive to existing tests because it changes how locust runs. But I do think people expect to be able to import modules in the same fashion as if they had run |
I understand the issue but I'm a little bit hesitant because of potential negative effects it might have (that are currently unknown to me). But I think I'm +0 at the moment. #1112 that was just merged makes it possible to avoid the issue by starting locust using |
@heyman merge or reject, I think it is up to you :) Like I said, I'm +1, but I dont need this change myself, so it's not that important to me... |
Okay, let's merge it. It solves a real issue, and if we realize that it creates other issues at some point in the future we can always re-evaluate :). |
rationale
I maintain multiple load tests, each with their own locustfile. They each
share helper utilities located at the project root, but
locust/main.py
loadsthe locustfile in a way that does not make importing the helpers easy. I have
to add the following line to every locustfile to make sure the helper utilities
are importable:
Then I invoke locust from the project root:
I think it's understandable why
locust/main.py
inserts the locustfiledirectory into the sys.path before loading it. I also think it would be
harmless to also make sure the current working directory is in the sys.path.
minimal example
directory structure:
helpers/__init__.py
:loadtests/test1/__init__.py
:loadtests/test1/locustfile.py
:testing running locust without this patch
Before this change, the common
helpers
module could not be found.testing running locust with this patch