-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
Tests for feedstock_io #357
Conversation
Very nice! I will find some time to review this tomorrow. Let me ask, would you guys consider using pytest for the tests? If it is a possibility, I could rewrite this module using pytest so you can compare and see if it is worth it. Also, pytest can run unittest's tests out of the box so it is easy to switch over. |
3c2571a
to
6b9bdf0
Compare
self.assertEqual(file_mode & set_mode, set_mode) | ||
|
||
|
||
def test_set_mode_file_2(self): |
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.
test_set_mode_file_1
and test_set_mode_file_2
are very similar, I think we can remove one of them.
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.
Yeah, so I had added duplicates of these as I started running into issues with absolute paths vs relative paths locally. Have made some fixes to conda-smithy
to handle these, but felt they should be tested somehow.
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.
Oh I see, I guess we can leave them in this case.
Those would be a prime candidate for parametrization if we were using pytest, btw. 😉
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.
Should add this is what is going on with all the other *_1
and *_2
. Definitely agree that it is kind of obnoxious to have so many like this.
with fio.write_file(filename) as fh: | ||
fh.write(write_text) | ||
|
||
read_text = "" |
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.
Small nit: this line is not needed
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.
True throughout. It's my C/C++ programmer side getting in the way. To use to thinking about scope in this way. Can drop them if you wish.
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.
Up to you. 😁
with fio.write_file(filename) as fh: | ||
fh.write(write_text) | ||
|
||
read_text = "" |
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.
Small nit: this line is not needed
with fio.write_file(filename) as fh: | ||
fh.write(write_text) | ||
|
||
read_text = "" |
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.
Small nit: this line is not needed
|
||
fio.touch_file(filename) | ||
|
||
read_text = "" |
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.
Small nit: this line is not needed
with fio.write_file(filename) as fh: | ||
fh.write(write_text) | ||
|
||
read_text = "" |
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.
Small nit: this line is not needed
|
||
fio.touch_file(filename) | ||
|
||
read_text = "" |
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.
Small nit: this line is not needed
|
||
fio.touch_file(filename) | ||
|
||
read_text = "" |
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.
Small nit: this line is not needed
filename = "dir1/dir2/test.txt" | ||
dirname = os.path.dirname(filename) | ||
|
||
if dirname and not os.path.exists(dirname): |
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.
Small nit: this line is not needed, the directory will never exist because setUp
creates a fresh directory
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.
This was probably some copypasta. Good catch.
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.
Fixed. 😄
self.assertTrue(os.path.exists(filename2)) | ||
self.assertTrue(list(self.repo.index.iter_blobs(BlobFilter(filename2)))) | ||
|
||
read_text = "" |
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.
Small nit: this line is not needed
Sorry I hadn't answered this yet. So my primary concern is that the test coverage is miserable in I think we were running the test suite with Have to confess I really don't have much experience with |
Sure. IMHO using pytest just as a test runner is useful, because you can use plain
IMHO it is very flexible, but of course as a maintainer that would be my opinion. 😁 If it is alright with you then, I will work on a PR that makes conda-smithy use pytest as test runner, and convert some (or all) of the tests to pytest's style. Sounds good? |
Go for it. 👍 Feel free to pull these tests in too if you wish. It'd be nice if @pelson could weigh in as I don't know his preferences, but I think he is otherwise engaged ATM. |
9cea999
to
2f55bf2
Compare
Have rebased this now that coverage is being checked by Coveralls. |
ec89542
to
9e0f7e3
Compare
9e0f7e3
to
21221c2
Compare
Thanks for your feedback @nicoddemus . Have consolidated the various parameterizations of these tests into single unit test functions that loop over those permutations. Hopefully this keeps the maintenance burden low. Will go ahead and put this in for now so we can ensure these functions remain correct. Though still would be interested to see your pytest version of this and/or other tests in |
Sure, will do probably this week! 😁 |
This is a follow-up on PR ( #336 ).
Adds a bunch of tests for the
feedstock_io
module. Tests exist for both the presence and absence of a git repo. The combination of these should help improve test coverage ofconda-smithy
particularly on these low level aspects.cc @nicoddemus