Tidbits | June 15, 2018

pytest support for django-test-plus

by Frank Wiles |   More posts by Frank

We're obviously fans of django-test-plus, having written it, and have found it very valuable over the last few years at cutting down on all of the boilerplate test code we have to write with our clients.

It even helps sell certain stubborn clients on the idea that testing can be done in a not so painful way!

Today we're happy to announce that you can now use django-test-plus as a real pytest fixture. Here's a quick example:

def test_some_view(tp):

def test_some_url_stuff(tp):
    expected_url = '/api/'
    reversed_url = tp.reverse('api')
    assert expected_url == reversed_url

And you get all of the other test plus methods as part of that "tp" fixture. This is a new experimental feature, so we'd love to hear how we can make this better and more "pytest like".

To start using all you need to do is install it and pull in "tp" as a fixture, you install it with just:

pip install django-test-plus

django-test-plus has long been a useful helper library with Django. Now we've added some simple pytest fixture support to make it even more useful!{% else %}

2018-06-15T16:02:34.863049 2018-06-15T16:21:11.174588 2018