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

Create separate base classes for shared tests #93

Merged
merged 5 commits into from
Feb 21, 2024
Merged

Conversation

mikealfare
Copy link
Contributor

@mikealfare mikealfare commented Feb 16, 2024

blocks dbt-labs/dbt-postgres#18

Problem

There are some tests in the "adapter zone" which do not have base classes. When these tests are imported, they run automatically due to how pytest works. This makes it impossible to configure the test if changes are required for a specific platform.

Solution

  • Update the test class name to not start with "Test" (which is what triggers pytest to execute it)
  • Create a new test class with the with same name that inherits the base class and does nothing for backwards compatibility

For example, this:

class TestFoo:
    def test_bar(self):
        assert baz == "baz"

becomes:

class BaseFoo:
    def test_bar(self):
        assert baz == "baz"


class TestFoo(BaseFoo):
    pass

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX

… into adapter implementations without running automatically
@mikealfare mikealfare self-assigned this Feb 16, 2024
Copy link

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@mikealfare mikealfare marked this pull request as ready for review February 20, 2024 18:43
@mikealfare mikealfare requested a review from a team February 20, 2024 18:44
Copy link
Contributor

@VersusFacit VersusFacit left a comment

Choose a reason for hiding this comment

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

Couple nits

@mikealfare
Copy link
Contributor Author

Couple nits

Good questions. I spent a good 15-30 minutes figuring out why the rename looked like it did. It turns out to be correct, but very misleading. So now we have the why captured in this PR.

@mikealfare mikealfare merged commit 863eb05 into main Feb 21, 2024
6 checks passed
@mikealfare mikealfare deleted the setup-shared-tests branch February 21, 2024 03:01
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.

3 participants