]> gitweb.fperrin.net Git - djsite.git/blobdiff - quotes/test_quotes.py
Start using pytest
[djsite.git] / quotes / test_quotes.py
index 36dcc1d1cd1aa3d7cd84f40ad40d0a3e1571b424..250ff3005aad3ba84541d49891dacb8e20a33093 100644 (file)
@@ -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="<p>Ich bin...</p>", 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="<p>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):