X-Git-Url: http://gitweb.fperrin.net/?p=djsite.git;a=blobdiff_plain;f=quotes%2Ftest_quotes.py;h=250ff3005aad3ba84541d49891dacb8e20a33093;hp=36dcc1d1cd1aa3d7cd84f40ad40d0a3e1571b424;hb=7d4d3d9380deb5d784cf52f9f3f136a551e5c522;hpb=e08dcd0cd0d71f65cb6fad387cbe2956ed55f0e4 diff --git a/quotes/test_quotes.py b/quotes/test_quotes.py index 36dcc1d..250ff30 100644 --- a/quotes/test_quotes.py +++ b/quotes/test_quotes.py @@ -1,23 +1,27 @@ from django.test import TestCase, Client # Create your tests here. +import pytest + from .models import QuoteTag, Author, Work, Quote import re import lxml.etree -class QuoteTest(TestCase): - def setUp(self): +class Test_QuoteTest(): + @pytest.fixture(scope='function') + def q1(self, db): a1 = Author.objects.create(name="JFK") w1 = Work.objects.create(name="Berlin speech", author=a1) q1 = Quote.objects.create(text="

Ich bin...

", work=w1) - self.q1 = q1 + return q1 - def test_one(self): + @pytest.mark.django_db + def test_one(self, q1): q = Quote.objects.filter(text__startswith="

Ich") - self.assertEqual(q.count(), 1) + assert q.count() == 1 q = q[0] - self.assertEqual(q, self.q1) - self.assertEqual(q.work.author.name, "JFK") + assert q == q1 + assert q.work.author.name == 'JFK' class ViewsTest(TestCase): def getPage(self, url, exp_status=200):