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

Move towards pytest style tests #4193

Closed
jdufresne opened this issue Nov 3, 2019 · 5 comments
Closed

Move towards pytest style tests #4193

jdufresne opened this issue Nov 3, 2019 · 5 comments
Labels
Projects

Comments

@jdufresne
Copy link
Contributor

Is the project interested in moving to use pytest conventions? This would mean something of the lines:

  • Use assert instead of unittest assert methods
  • Removing unittest classes
  • Using fixtures for stdout/stderr capturing, temporary files, and more (and perhaps some internal ones too.)
  • Using parameterized tests?

If so, I can help out here and there. As there are quite a lot of tests, it might make sense to this on a file by file basis or in pieces.

Thoughts?

@mfonism
Copy link

mfonism commented Nov 15, 2019

I'm interested in helping out with this.

@aclark4life aclark4life added this to New Issues in Pillow Jan 9, 2020
@hugovk
Copy link
Member

hugovk commented Jan 18, 2020

Well, no one has objected yet!

I had originally wanted to keep things fairly agnostic with regards third-party tools, to stick with the stdlib unittest for the tests.

But that was when there was nose, nose2 and pytest, in addition to unittest. Now:

  • Nose is in maintenance mode with no updates for 4 years (but still 3m downloads per month)
  • Nose2 (165k/m) is still going but mainly maintained for those "stuck" using it and they encourage people new to testing to try pytest
  • Pytest (12m/m) is very popular and well-maintained, and arguably becoming a standard for unit tests

So I'd be up for giving it a go.

I'd suggest to try and keep the main usage of it fairly simple, so there's a low barrier for new contributors looking at tests. Although parameterised tests could certainly be used in a few cases, it's a good way to remove duplication. And if any other pytest things are really helpful, then let's have a look at that too.

If so, I can help out here and there. As there are quite a lot of tests, it might make sense to this on a file by file basis or in pieces.

I agree, it definitely makes sense to do it in parts rather than one big bang.

Would you be able to do a smallish PR so we can see how it looks?

Thank you!

@jdufresne
Copy link
Contributor Author

A first pass as the easier tests to port: #4369

@radarhere
Copy link
Member

unittest is no longer in Pillow. Long live pytest

Is this issue resolved?

@jdufresne
Copy link
Contributor Author

Makes sense to me. Nice work everyone.

Pillow automation moved this from New Issues to Closed Mar 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Pillow
  
Closed
Development

No branches or pull requests

4 participants