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

pytest-django youtube video code #5

Open
bbelderbos opened this issue Jun 22, 2023 · 0 comments
Open

pytest-django youtube video code #5

bbelderbos opened this issue Jun 22, 2023 · 0 comments

Comments

@bbelderbos
Copy link
Collaborator

Code from https://youtu.be/L5jWFU2sVXQ

pytest.ini

[pytest]
DJANGO_SETTINGS_MODULE = mysite.settings
python_files = tests.py test_*.py *_tests.py
filterwarnings =
     ignore::django.utils.deprecation.RemovedInDjango50Warning

tests/test_blog.py (ran black after recording):

import pytest

from blog.views import blog_list
from blog.models import Blog


@pytest.fixture
def blog_entry(db):
    return Blog.objects.create(
        title="Test Blog",
        post="Test Body",
        slug="test-blog",
        cover="test.jpg",
        added="2019-01-01",
        edited="2019-01-01",
    )


def test_blog_list(client, blog_entry):
    ret = client.get("/")
    assert ret.status_code == 200
    assert list(ret.context["posts"]) == [blog_entry]
``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant