import pytest from .models import Author, Work, Quote class Test_Search(): @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) return q1 @pytest.mark.django_db def test_search(self, q1, c): results = c.postPage('search/', {'q': 'Ich'}) assert 'JFK' in results @pytest.mark.django_db def test_emptysearch(self, q1, c): assert c.postPage('search/', {'q': 'something that matches nothing'})