-
Notifications
You must be signed in to change notification settings - Fork 83
Eliminate Path(__file__) to locate resource files
#2210
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
Conversation
…ed for tests. This removes the need for `Path(__file__)`-based manipulation.
|
✅ 129/129 passed, 7 flaky, 5 skipped, 19m12s total Flaky tests:
Running from acceptance #3443 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2210 +/- ##
=======================================
Coverage 64.05% 64.05%
=======================================
Files 100 100
Lines 8624 8625 +1
Branches 893 889 -4
=======================================
+ Hits 5524 5525 +1
Misses 2928 2928
Partials 172 172 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
In addition, update tests: - No more Path(__file__) manipulation. - Test pipeline configurations now use paths relative to the test resources.
| from ..conftest import FunctionalTestFile, FunctionalTestFileWithExpectedException, get_functional_test_files | ||
|
|
||
|
|
||
| def pytest_generate_tests(metafunc: pytest.Metafunc) -> None: |
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 see you moved test_databricks to test_snowflake
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.
Indeed, the pattern for the other ones is to name these after the source system. So the changes here are:
- The snowflake ones were moved from
test_databricks.pytotest_snowflake.py. - There were 2 sets of functional tests for each source system, in separate files: I've moved them into the same file.
gueniai
left a comment
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.
LGTM
## Changes ### What does this PR do? This PR eliminates the use of `Path(__file__)` to locate file-based resources. In general: - In the main code, this is buggy: modern Python should use `importlib.resources` instead. - In tests, it's brittle and difficult to read because it's normally based on relative paths and traversal of many parent directories. It's also unnecessary, because pytest provides a mechanism for locating the project root. (Tests can also use `importlib.resources`, and probably should, but that's a bigger refactoring: this is a first step.) Some incidental changes that are introduced: - Type hints in a few places. - Functional tests against Snowflake, Oracle and Presto have been consolidated into a single module. (The Snowflake functional tests have been moved into `test_snowflake.py`: `test_databricks.py` was misleading.) - The `PipelineConfig` (and `Step`) classes have been made immutable. (An unnecessary `__post__init()` method has also been eliminated.) ### Tests - existing unit tests - existing integration tests
Changes
What does this PR do?
This PR eliminates the use of
Path(__file__)to locate file-based resources. In general:importlib.resourcesinstead.importlib.resources, and probably should, but that's a bigger refactoring: this is a first step.)Some incidental changes that are introduced:
test_snowflake.py:test_databricks.pywas misleading.)PipelineConfig(andStep) classes have been made immutable. (An unnecessary__post__init()method has also been eliminated.)Tests