I ran in to an issue filling in the environment fields on Allure reports for pytest. The issue was, the environment field was not being filled in correctly when the report was generated.

I tried a couple of different things, and this is what wound up working.

# Drop in to conftest.py
import allure


@pytest.hookimpl(trylast=True)
def pytest_configure(config):  
    allure.environment(
        url='broadly.vice.com',
        browser=u'Google Chrome',
        environment="production",
    )

I'm guessing the reason is, is because the pytest_configure method gets ran multiple times and the initial setting of those values is lost in the process.

Side note - Any custom kwargs you use will appear in the report also.

© 2017. All Rights Reserved.