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

Add zeros to test_names to fix the running order. #54

Merged
merged 8 commits into from
Oct 7, 2017

Conversation

deepjia
Copy link
Contributor

@deepjia deepjia commented Oct 4, 2017

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 after test_Case_19_*, which is not expected.

@codecov-io
Copy link

codecov-io commented Oct 5, 2017

Codecov Report

Merging #54 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #54   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines         107    110    +3     
=====================================
+ Hits          107    110    +3
Impacted Files Coverage Δ
ddt.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5e81603...76aba8b. Read the comment docs.

@txels
Copy link
Collaborator

txels commented Oct 5, 2017

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
Copy link
Collaborator

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
Copy link
Collaborator

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.

@deepjia
Copy link
Contributor Author

deepjia commented Oct 6, 2017

Fixed them, and thanks for your instructions.

@@ -255,6 +255,7 @@ class Mytest(object):
def test_hello(self, val):
pass

print(Mytest.__dict__)
Copy link
Collaborator

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!

Copy link
Contributor Author

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.

@txels txels merged commit f2b1caa into datadriventests:master Oct 7, 2017
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.

None yet

3 participants