pytest test order effects

I have set up some tests in pytest, some are normal TestCases under the hood, but I also have a live_server test case. (I asked about why the live_server was showing up as https here last week.)

I didn’t realise at the time, but have found that the bundled live_server fixture affects database access for every test that happens after it - so a number of tests which access the database (e.g. to get a user to force_login) will pass if they are before the live server test, and fail if they are after. I think (?) this bug relates: https://github.com/pytest-dev/pytest-django/issues/454

The recommended solution there (wrapping the live_server fixture as a fixture with ‘function’ scope) did not seem to work for me. The same error occurs. For example, this very simple test using the test client:

@pytest.mark.django_db
def test_get_admin_as_admin(client):
    """this tests if the user is redirected when not logged in, and granted access when logged in with a 
    superuser account."""
    response=client.get("/admin/")  # not logged in, no access, redirect
    print(response.url)
    assert response.status_code == 302

    user = User.objects.get(username="admin") # logged in, superuser, grant
    client.force_login(user)
    response = client.get("/admin/")
    assert response.status_code == 200

This test passes when run by itself, but fails if run after the live_server selenium test.

@pytest.mark.django_db
def test_page_clicking(live_server):
    """To run this test you must have Firefox & the 'geckodriver installed on the appropriate path."""
    s = Service("geckodriver.exe")
    ff_driver = webdriver.Firefox(service=s)
    live_url_http = "http"+live_server.url[5:]  # solves live_server wrongly claiming https support
    ff_driver.get(live_url_http+"/")
    ff_driver.get(live_url_http + "/accounts/login/")
    input_username = ff_driver.find_element(By.ID,"id_username")
    input_username.send_keys("admin")
    input_password = ff_driver.find_element(By.ID,"id_password")
    input_password.send_keys("Alphabet1:0")
    input_password.submit()
    # without a wait the log on is not completed and adding the 'save_screenshot' seemed more effectual than this WDWait
    time.sleep(2)
    ff_driver.close()

The Selenium test passes, but after it runs the test database is rolled back to an empty state instead of a state with fixture data loaded. Here is the fixture:

@pytest.fixture(scope="session")
def django_db_setup(django_db_setup, django_db_blocker):
    """load_json loads the output of dumpdata after deleting the ContentType and Permission objects 
     created by initial migrations.  They are replaced by the versions in the json file that are coherent 
    with the rest of the objects."""
    with django_db_blocker.unblock():
        load_json_into_fresh_database("tests/test_fixtures/db_dev.json")

The error is “User matching query does not exist.” A test on ContentTypes runs, trivially, so I reckon the fixture being invoked first by the live_server has wrapped the data loading step in the transaction, but I’m at a bit of a loss as to how to address this. Put Zs at the start of live_server tests?