I try to make a test with has an error
any suggestions?
tim

    expected_author = f'{post.author}
                                    ^
SyntaxError: EOL while scanning string literal


----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)
Destroying test database for alias 'default'...
MacBook-Pro-15-Officerebel:blogapi timvogt$


from django.test import TestCase
from django.contrib.auth.models import User

from .models import Post

class BlogTests(TestCase):

    @classmethod 
    def setUpTestData(cls):
        #Create a user
        testuser1 = User.objects.create_user(
            username='testuser1', password='abc123')
        testuser1.save()

        # Create a blog post
        test_post = Post.objects.create(
            author=testuser1, title='Blog title', body='Body content...')
        test_post.save()

    def test_blog_content(self):
        post = Post.objects.get(id=1)
        expected_author = f'{post.author}'
        expected_title = f'{post.title}'
        expected_body = f'{post.body}'
        self.assertEquals(expected_author, 'testuser1')
        self.assertEquals(expected_title,'Blog title')
        self.assertEquals(expected_body, 'Body content ...')

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/FCBEF0A0-EDB1-4842-BB4E-42249F3F48EB%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to