Skip to content

Adding pytest to project#313

Merged
sveinse merged 7 commits intocustom-components:masterfrom
sveinse:feature-add-testing
Aug 31, 2025
Merged

Adding pytest to project#313
sveinse merged 7 commits intocustom-components:masterfrom
sveinse:feature-add-testing

Conversation

@sveinse
Copy link
Collaborator

@sveinse sveinse commented Aug 31, 2025

Fix #262

@sveinse sveinse added this to the v0.8.3 milestone Aug 31, 2025
Copy link
Contributor

@steinmn steinmn left a comment

Choose a reason for hiding this comment

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

LGTM, will probably need a little bit of coordination to add both this and #307 to validate.yaml

@@ -45,3 +45,25 @@ jobs:
with:
args: check --exit-zero # succeed despite errors until https://github.com/custom-components/zaptec/issues/258 is done
src: "."
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to include the tests in the ruff check? (ref modification to exclude scripts in #307)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(I was about to ask you the same question.) That up to us, really. I've been working with projects that have both with or without ruff in tests/. I think the argument goes something along the lines that the test code is an equal important piece of the quality of the code, hence it should have the same scrutiny as the main code. The other argument goes that tests often require some non-pythonic constructs and that following every rule in tests is being somewhat pedantic.

I'm leaning towards not including tests into the ruff check (for now at least). But I'm very keen on hearing your opinion before we settle this.

Copy link
Contributor

Choose a reason for hiding this comment

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

From what I can tell, HA-core runs it on all files. So I'm inclined to say include tests for now, and if it gets really annoying/tedious, we can consider excluding it again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. Smart to check what HA does. Then I agree, let's leave it to also check tests.

@sveinse
Copy link
Collaborator Author

sveinse commented Aug 31, 2025

LGTM, will probably need a little bit of coordination to add both this and #307 to validate.yaml

I plan to to the merges in order, so #307 goes first and then I'll fixup any merge conflicts that might result in this PR.

Are there any data content we need to coordinate as well here?

@steinmn
Copy link
Contributor

steinmn commented Aug 31, 2025

Are there any data content we need to coordinate as well here?

I think it's just a matter of setting src: ["custom_components/zaptec", "tests"] for the ruff check both in the lint-script and validate.yaml

Updated ruff check source path to include tests.
@sveinse
Copy link
Collaborator Author

sveinse commented Aug 31, 2025

I added ruff check of tests to this PR. Please take a look at the results from the latest run. I see a few errors from ruff that we have to address to not get swamped by warnings. E.g. that assert has been encountered (which is expected in pytest).

@sveinse sveinse merged commit 2545e4b into custom-components:master Aug 31, 2025
6 checks passed
@sveinse sveinse deleted the feature-add-testing branch August 31, 2025 20:50
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.

Add pytest setup

2 participants