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:
timestamp = time.strftime('%y%m%d-%H%M%S')
# the following are used by conftest.py
output_path = utils.generate_output_path(timestamp)
folder = utils.create_output_folder(output_path)
def main():
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)
if __name__ == "__main__":
main()
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?