-
Notifications
You must be signed in to change notification settings - Fork 112
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
Add zeros to test_names to fix the running order. #54
Conversation
Codecov Report
@@ Coverage Diff @@
## master #54 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 1 1
Lines 107 110 +3
=====================================
+ Hits 107 110 +3
Continue to review full report at Codecov.
|
Thanks for this. Makes sense. |
ddt.py
Outdated
# Add zeros before index to keep order | ||
index = str(index + 1) | ||
if len(index) < I_LEN: | ||
index = '0' * (I_LEN - len(index)) + index |
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.
There are nicer ways to let python do the zero-filling for you e.g. a couple answers here: https://stackoverflow.com/a/135157/166761
ddt.py
Outdated
@@ -27,6 +27,8 @@ | |||
DATA_ATTR = '%values' # store the data the test must run with | |||
FILE_ATTR = '%file_path' # store the path to JSON file | |||
UNPACK_ATTR = '%unpack' # remember that we have to unpack values | |||
# Digits of the largest index for list/tuple, or default = 5 for generator | |||
I_LEN = len(str(len(DATA_ATTR))) if isinstance(DATA_ATTR, (list, tuple)) else 5 |
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 don't think this does what you think it does. This expression will always return a five, as it is computed statically upon module loading.
What you may want to do is compute this value dynamically, ideally based on the number of values that are provided via the data decorator.
Fixed them, and thanks for your instructions. |
test/test_functional.py
Outdated
@@ -255,6 +255,7 @@ class Mytest(object): | |||
def test_hello(self, val): | |||
pass | |||
|
|||
print(Mytest.__dict__) |
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.
Can you remove this line? And I'll merge this. Thanks!
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.
Forgot to del that. Removed.
Add zeros to index in test_name to fix the running order when there are more than 9 cases.
Since
'_' > '9'
,test_Case_1_*
will always run aftertest_Case_19_*
, which is not expected.