jeudi 1 mars 2018

dynamically creating output folder based on timestamp

I used to use a runner.py with my pytest framework in order to get around the bug with combining markers and string params, e.g. -k 'foo' -m 'bar'.

I also used the runner to get the test run's starting timestamp and create an output folder output// to which I write my logs and the html report, save any screenshots, etc.

runner.py excerpt:

    args = sys.argv[1:]
    args.append('-v')
    args.append('--timestamp=%s' % timestamp)
    args.append('--output_target=%s' % folder)
    args.append('--html=%s/results.html' % folder)
    pytest.main(args, plugins=plgns)

I want to lose the runner.py and use straight CLI args and fixtures/hooks but not manually pass in timestamp, output_target, or the html report path, but have so far been unable find a way to change that config, for example by modifying config.args. How can I dynamically write timestamp, output_target, and the html path so that pytest uses them during initialization?

Aucun commentaire:

Enregistrer un commentaire