-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Setup python paths in test runner configuration #20832
Conversation
Use the python tests runner to setup python paths so each test doesn't need to setup their own python paths.
Pinging @elastic/integrations (Team:Integrations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to have the import statements match the project structure so that when you see an import statement you can know exactly where the file is coming from (like import libbeat.tests.system.beat.compose
). Then the only addition to sys.path
is the repository root. Would it be possible to implement that? Would you still need one conftest.py for every beat project?
It is not very common to have so long import paths in python. Usually the modules are in some path, and one adds this path to their python path.
Something we could do if we want to have a single |
Another problem with this is that we have python code under directories with hyphens (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining the reasons why my suggestion would not work. I'm not much of a python developer (nor do I want to be 😆 ). I think this approach of moving the sys.path
manipulation out of the code is clean.
I am merging this as it removes python path configuration from tests, what I think is an improvement. |
Use the python tests runner to setup python paths so each test doesn't need to setup their own python paths. (cherry picked from commit 42a53eb)
…ne-2.0 * upstream/master: (87 commits) [packaging] Normalise GCP bucket folder structure (elastic#20903) [Metricbeat] Add billing metricset into googlecloud module (elastic#20812) Include python docs in devguide index (elastic#20917) Avoid generating incomplete configurations in autodiscover (elastic#20898) Improve docs of leaderelection configuration (elastic#20601) Document how to set the ES host and Kibana URLs in Ingest Manager (elastic#20874) docs: Update beats for APM (elastic#20881) Adding cborbeat to community beats (elastic#20884) Bump kibana version to 7.9.0 in x-pack/metricbeat (elastic#20899) Kubernetes state_daemonset metricset for Metricbeat (elastic#20649) [Filebeat][zeek] Add new x509 fields to zeek (elastic#20867) [Filebeat][Gsuite] Add note about admin in gsuite docs (elastic#20855) Ensure kind cluster has RFC1123 compliant name (elastic#20627) Setup python paths in test runner configuration (elastic#20832) docs: Add `processor.event` info to Logstash output (elastic#20721) docs: update cipher suites (elastic#20697) [ECS] Update ecs to 1.6.0 (elastic#20792) Fix path in hits docs (elastic#20447) Update filebeat azure module documentation (elastic#20815) Remove duplicate ListGroupsForUsers in aws/cloudtrail (elastic#20788) ...
Use the python tests runner to setup python paths so each test doesn't need to setup their own python paths.
Add
conftest.py
files to projects with python tests. This file is imported by the test runner. Use it to setup python paths so tests don't need to care about them depending on where they are located, and we control paths from central points.