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

Adds unique tests names validator #7

Merged
merged 8 commits into from
Dec 1, 2020

Conversation

lowitea
Copy link
Contributor

@lowitea lowitea commented Oct 1, 2020

closes #3

@lowitea lowitea mentioned this pull request Oct 1, 2020
error_msg = self.error_template.format(node_name)
self.add_error((node.lineno, 0, error_msg))

def _is_properly_node(self, node: ast.AST) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

This is copy paste. We use this method already in 3 places and 2 of them have similar code. I think we should move this method to BaseWatcher, make it public, and override where we need other logic (like here)

Copy link
Contributor

Choose a reason for hiding this comment

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

By the way, we have similar case in another PR. Please, take a look, maybe we will do it earlier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed 35f68b6

Copy link
Contributor

Choose a reason for hiding this comment

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

Have a comment

@mcproger
Copy link
Contributor

@lowitea also please, update README with this feature description.

@lowitea lowitea requested a review from mcproger November 28, 2020 22:35
return

for node in ast.walk(self.tree):
if not self._is_test_function(node):
Copy link
Contributor

Choose a reason for hiding this comment

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

Almost done :)

Better call _should_check_node method in this place. This is because the should_check method tells us whether handle this node or just skip it. By default, this method checks that node is test function.
But it can be something else, for example here we need more complex condition to check. So, we are overriding the default behavior and keeping the methods naming consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

@mcproger
Copy link
Contributor

@lowitea take a look at this comment, please.

Also, you have a broken build. Please fix it, before merge.

@lowitea
Copy link
Contributor Author

lowitea commented Nov 29, 2020

I updated readme and fixed ci. But maybe there is a regression after #8. I am failing tests with examples like this:

@ pytest.mark.parametrize ('test', ('test',))
def test_not_uniq_with_decorator (test):
     pass


@ pytest.mark.parametrize ('test', ('test2',))
def test_not_uniq_with_decorator (test):
     pass

Fell with error "FP009 test_not_uniq_with_decorator should use fixtures as follows"
@mcproger look at this please

@lowitea
Copy link
Contributor Author

lowitea commented Nov 29, 2020

Nevertheless, I fixed the tests. A bug or a feature, but definitely does not apply to the current issue

@lowitea lowitea requested a review from mcproger November 29, 2020 18:41
@mcproger mcproger merged commit 707ce5e into best-doctor:master Dec 1, 2020
@mcproger
Copy link
Contributor

mcproger commented Dec 1, 2020

Nice job :)
Thanks for your help

@lowitea lowitea deleted the unique_tests branch December 1, 2020 08:33
micheller added a commit to micheller/flake8-fine-pytest that referenced this pull request Dec 1, 2020
Adds unique tests names validator (best-doctor#7)
@lowitea
Copy link
Contributor Author

lowitea commented Dec 1, 2020

Hi @mcproger
I apologize for writing to you here, but I didn't come up with a better way(
Can I ask you (or someone else from your team) to look at my other pull requests

best-doctor/flake8-annotations-coverage#11
best-doctor/flake8-annotations-coverage#9
best-doctor/flake8-variables-names#8
best-doctor/flake8-annotations-complexity#15

@mcproger
Copy link
Contributor

mcproger commented Dec 6, 2020

Hi @lowitea

I didn't come up with a better way(

You can send me email :)

Can I ask you (or someone else from your team) to look at my other pull requests

Unfortunately, I am not a collaborator of these projects. I'll ask my team, but I'm afraid it may take a while.

@lowitea
Copy link
Contributor Author

lowitea commented Dec 6, 2020

@mcproger unfortunately I could not find your email

ok, thanks a lot anyway

@mcproger
Copy link
Contributor

mcproger commented Dec 6, 2020

@lowitea you can see it in my profile – [email protected]

@lowitea
Copy link
Contributor Author

lowitea commented Dec 6, 2020

@lowitea you can see it in my profile – [email protected]

Thanks!)

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.

Validate unique tests names
2 participants