On 6 April 2014 17:24, Andrew Pashkin <[email protected]> wrote:
> Some Pytest advocacy:
> 1) Pytest has convenient tests collection options - you can just specify
> folder to run all tests in it. It is also possible to filter tests by regex,
> and select specific ones.

Sounds good, but unittest's test discovery is not that bad and can be
easily improved.

>
> 2) PyUnit:
>
> class MyTestCase(TestCase):
>     def test_something(self):
>        expected_content = ...
>        response = self.client(...)
>        self.assertEqual(expected_content, response.content)
>
> Pytest:
>
> def test_something(client):
> expected_content = ...
> response = self.client(...)
> assert expected_content == response.content
>
> Pytest style is cleaner and complies PEP8.

That is very subjective. Also, Python's standards library uses
unittest, so it's hard to argue that Pytest is more in line with
Python standard library recommendation (which what PEP8 is).

> Assertions with assert are more readable.

Again subjective and the magic involved in Pytest's "assertion
introspection" is rather scary. And you still need custom
methods/functions for non-trivial assertions like assertHTMLEquals or
assertQuerysetEquals.

> It is also possible to group tests, by placing them into class, without 
> subclassing something.

True, but Python is not Java, so I never found that to be a problem.

> 4) In Pytest it is possible to define setup functions for modules, classes
> and specific tests.

As in unittest:
https://docs.python.org/2/library/unittest.html#class-and-module-fixtures

> 6) pytest-xdist plugin provides parallel execution of tests.

The hard part when running tests in parallel is usually how to manage
shared resources (like the database - and no creating a new Oracle
instance in every subprocess is a non-starter!). So while having some
support for that is good, it's not something Django's test suite would
get for free.

> 5) Pytest also has fixture mechanism, which allows to use additional
> resources in tests by specifying fixture names as an arguments (like client)
> - it is good alternative to using setUp's and subclassing something.
> 7) Pytest has features for writing parametrized tests.
>

These two features are actually something worth looking at
(parametrized tests would allow cleaning up a lot of template tests),
but I'm guessing that for the core developers to get convinced you'd
have to show that this two will make a real difference (instead of
focusing on the less important stuff mentioned earlier).

Best regards,
Lucas Rekucki

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAEZs-EJM6tGxYsihgebYWXgX5uX3OLaJnrFZR3J1LDqxSa2xQg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to