Skip to content

Instantly share code, notes, and snippets.

@rg3915
Created December 30, 2022 13:27
Show Gist options
  • Save rg3915/6a14e36729167d827dd9aae17a6b03f1 to your computer and use it in GitHub Desktop.
Save rg3915/6a14e36729167d827dd9aae17a6b03f1 to your computer and use it in GitHub Desktop.
pytest
import pytest
from backend.accounts.models import User
@pytest.fixture
def user():
data = {
"first_name": "Regis",
"last_name": "Santos",
"email": "[email protected]"
}
user = User.objects.create(**data)
return user
[pytest]
DJANGO_SETTINGS_MODULE = backend.settings
python_files = tests.py test_*.py *_tests.py
from http import HTTPStatus
import pytest
from backend.accounts.models import User
@pytest.mark.django_db
def test_user_exists(user):
user_exists = User.objects.filter(email=user.email)
assert user_exists.exists()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment