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:

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:

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
    assert response.status_code == 302

    user = User.objects.get(username="admin") # logged in, superuser, grant
    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.

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 + "/accounts/login/")
    input_username = ff_driver.find_element(By.ID,"id_username")
    input_password = ff_driver.find_element(By.ID,"id_password")
    # without a wait the log on is not completed and adding the 'save_screenshot' seemed more effectual than this WDWait

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:

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():

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?