-
Notifications
You must be signed in to change notification settings - Fork 9
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
Safer generated test method names. #43
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
from mock import patch | ||
import six | ||
from genty import genty, genty_args, genty_dataset, genty_repeat, genty_dataprovider | ||
from genty.genty import REPLACE_FOR_PERIOD_CHAR | ||
from genty.private import encode_non_ascii_string | ||
from test.base_test_case import TestCase | ||
|
||
|
@@ -154,7 +155,7 @@ def test_decorated(self, value1, value2, value3): | |
)(), | ||
) | ||
|
||
def test_dataprovider_args_can_use_gentry_args(self): | ||
def test_dataprovider_args_can_use_genty_args(self): | ||
@genty | ||
class SomeClass(object): | ||
@genty_dataset( | ||
|
@@ -437,18 +438,47 @@ def test_unicode(self, _): | |
def test_genty_properly_composes_method_with_special_chars_in_dataset_name(self): | ||
@genty | ||
class SomeClass(object): | ||
@genty_dataset(*r'!"#$%&\'()*.+-/:;>=<?@[\]^_`{|}~,') | ||
@genty_dataset(*r'!"#$%&\'()*+-/:;>=<?@[\]^_`{|}~,') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why can't we test dots anymore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because they get changed to the middle-dot. And that case is tested below. |
||
def test_unicode(self, _): | ||
return 33 | ||
|
||
instance = SomeClass() | ||
|
||
for char in r'!"#$%&\'()*.+-/:;>=<?@[\]^_`{|}~,': | ||
for char in r'!"#$%&\'()*+-/:;>=<?@[\]^_`{|}~,': | ||
self.assertEqual( | ||
33, | ||
getattr(instance, 'test_unicode({0})'.format(repr(char)))() | ||
) | ||
|
||
def test_genty_replaces_standard_period_with_middle_dot(self): | ||
# The nosetest multi-processing code parses the full test name | ||
# to discern package/module names. Thus any periods in the test-name | ||
# causes that code to fail. This test verifies that periods are replaced | ||
# with the unicode middle-dot character. | ||
@genty | ||
class SomeClass(object): | ||
@genty_dataset('a.b.c') | ||
def test_period_char(self, _): | ||
return 33 | ||
|
||
instance = SomeClass() | ||
|
||
for attr in dir(instance): | ||
if attr.startswith(encode_non_ascii_string('test_period_char')): | ||
self.assertNotIn( | ||
encode_non_ascii_string('.'), | ||
attr, | ||
"didn't expect a period character", | ||
) | ||
self.assertIn( | ||
encode_non_ascii_string(REPLACE_FOR_PERIOD_CHAR), | ||
attr, | ||
"expected the middle-dot replacement character", | ||
) | ||
break | ||
else: | ||
raise KeyError("failed to find the expected test") | ||
|
||
def test_genty_properly_calls_patched_methods(self): | ||
class PatchableClass(object): | ||
@staticmethod | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What is this for?
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.
It tells nose's multi-processing logic that this single test class can be "split" across multiple processes.
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.
+1 - let's not commit this unless we plan to use multiprocess in our tox.ini
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 have it so that when manually testing... I can tickle the scenario. Without the fix the tests will fail. And with the fix the tests pass. So I think this should be committed. I can add a comment.