I would like to use pytest, pytest-django, and pytest-selenium together to test my Django application functionality. If I start the server manually with python manage.py runserver, and manually input the URL, it works fine.
The live_server fixture from pytest-django is supposed to start a server process in the background that I could use, but it's not working. Instead of a passing test, I get "The requested resource was not found on this server."
Here are the relevant sections of my files:
pytest.ini
[pytest]
DJANGO_SETTINGS_MODULE = chatsite_api.settings.test
addopts = --liveserver localhost:8080 --cov=. --cov-report=html --driver Firefox
test_pages.py
import pytest
def test_homepage(selenium, live_server):
selenium.get(live_server.url)
assert "Django: the Web framework" in selenium.title
And chatsite_api.settings.test.py
from .dev import * # NOQA
DATABASES = {"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}}
DEBUG = True
As I said, the tests run fine when I start the server myself, but the live_server fixture doesn't seem to be doing what it's supposed to. I have verified that the live_server.url is being set according to the addopts line in pytest.ini, but that is as far as I've gotten.