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

plugin: example raises AssertionError when regex does not match #1905

Merged
merged 1 commit into from
Jul 19, 2020

Conversation

Exirel
Copy link
Contributor

@Exirel Exirel commented Jul 15, 2020

Description

The decorator example generates a test function when used with pytest and an expected output. When a regex is used for said test, a fake assert expected == output was used to mark the test as failed. It is not adapted because a) if the assert pass, it means the test should not use a regex in the first place and b) it creates a confusing test output. So now, it raises an AssertionError with a proper error message, which is well understood by any test runner - after all, assert is a way to raise the exact same error.

Note: I use plugin: ... in the commit message because it's related to the sopel.plugin.example decorator, so it makes more sense to me.

Checklist

  • I have read CONTRIBUTING.md
  • I can and do license this contribution under the EFLv2
  • No issues are reported by make qa (runs make quality and make test)
  • I have tested the functionality of the things this change touches

@Exirel Exirel added this to the 7.1.0 milestone Jul 15, 2020
@Exirel Exirel requested a review from a team July 15, 2020 10:50
Copy link
Member

@dgw dgw left a comment

Choose a reason for hiding this comment

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

Honestly I'm surprised no one thought to make a change like this sooner. Test output is definitely confusing for regex examples with the plain old assert

@dgw dgw merged commit 9bcaf2f into sopel-irc:master Jul 19, 2020
@dgw dgw added the Tests label Jul 19, 2020
@Exirel Exirel deleted the test-tools-example-re-assert branch May 1, 2021 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants