Skip to content

Instantly share code, notes, and snippets.

@dchuvardynskyi
Created November 19, 2019 23:06
Show Gist options
  • Select an option

  • Save dchuvardynskyi/e50e6d38a9d9279140da821543abb925 to your computer and use it in GitHub Desktop.

Select an option

Save dchuvardynskyi/e50e6d38a9d9279140da821543abb925 to your computer and use it in GitHub Desktop.
Pytest Django client test with django_user_modle fixture
import pytest
from django.urls import reverse
@pytest.mark.django_db
def test_user_detail(client, django_user_model):
user = django_user_model.objects.create(
username='someone', password='password'
)
url = reverse('user-detail-view', kwargs={'pk': user.pk})
response = client.get(url)
assert response.status_code == 200
assert 'someone' in response.content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment