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

Tests for feedstock_io #357

Merged
merged 10 commits into from
Nov 5, 2016
Merged

Conversation

jakirkham
Copy link
Member

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 of conda-smithy particularly on these low level aspects.

cc @nicoddemus

@jakirkham jakirkham changed the title Test for feedstock_io Tests for feedstock_io Nov 2, 2016
@nicoddemus
Copy link
Member

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.

@jakirkham jakirkham force-pushed the test_feedstock_io branch 8 times, most recently from 3c2571a to 6b9bdf0 Compare November 2, 2016 05:17
self.assertEqual(file_mode & set_mode, set_mode)


def test_set_mode_file_2(self):
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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. 😉

Copy link
Member Author

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 = ""
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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 = ""
Copy link
Member

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 = ""
Copy link
Member

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 = ""
Copy link
Member

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 = ""
Copy link
Member

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 = ""
Copy link
Member

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 = ""
Copy link
Member

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):
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member Author

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 = ""
Copy link
Member

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

@jakirkham
Copy link
Member Author

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.

Sorry I hadn't answered this yet. So my primary concern is that the test coverage is miserable in conda-smithy. Any way we can improve that gets a 👍 from me.

I think we were running the test suite with nose before, but AFAICT everything uses unittest. Also did a little cleanup ( #355 ) so that we don't really need nose at all.

Have to confess I really don't have much experience with pytest having used nose or unittest in the past. Though am definitely interested in learning. The vast number of plugins for pytest gives me hope that it is really flexible under the hood. Have some other non-conda-forge activities that would really benefit from such a flexible testing framework.

@nicoddemus
Copy link
Member

Have to confess I really don't have much experience with pytest having used nose or unittest in the past.

Sure. IMHO using pytest just as a test runner is useful, because you can use plain assert statements instead of having to use self.assert* functions.

The vast number of plugins for pytest gives me hope that it is really flexible under the hood. Have some other non-conda-forge activities that would really benefit from such a flexible testing framework.

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?

@jakirkham
Copy link
Member Author

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.

@jakirkham jakirkham force-pushed the test_feedstock_io branch 3 times, most recently from 9cea999 to 2f55bf2 Compare November 5, 2016 21:23
@jakirkham
Copy link
Member Author

Have rebased this now that coverage is being checked by Coveralls.

@jakirkham
Copy link
Member Author

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 conda-smithy.

@jakirkham jakirkham merged commit d60880c into conda-forge:master Nov 5, 2016
@jakirkham jakirkham deleted the test_feedstock_io branch November 5, 2016 22:54
@nicoddemus
Copy link
Member

Though still would be interested to see your pytest version of this and/or other tests in conda-smithy.

Sure, will do probably this week! 😁

@nicoddemus nicoddemus mentioned this pull request Nov 15, 2016
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.

2 participants