Search code examples
seleniumpytestpytest-html

How to list installed packages and environment variables in pytest-html report?


I have a framework with selenium + python tests and I need to use pytest-html to get and show the info about installed packages and environment variables in the generated report. My only thought was to get extra.html and write a scipt which will run pip list for packages but this looks like an overhead.

Any advices are greatly appreciated.


Solution

  • Well, turned out it was pretty easy to do. I had to use common os library:

    import os
        def _pytest_configure_(config):
            config.metadata['os'] = os.name
            config.metadata['PATH'] = os.environ['PATH']
            config.metadata['pwd'] = os.getcwd()
    

    and put this into a repor, then run python3 -m pytest -v --html=report.html