def test_config_file_permission_no_warning(): with set_config_file() as config_file: with pytest.warns(None) as record: global_config_file = get_global_config_file() assert str(global_config_file) == str(config_file) assert len(record) == 0, ( "A warning was issued while it should not have.\n" f"Warning is: {record[0]}")
def config(ctx, benchmark, token=None, filename=None): ctx.ensure_object(dict) if benchmark is None: config = get_global_config_file() else: benchmark = Benchmark(benchmark) config = benchmark.get_config_file() if ctx.invoked_subcommand is None: print(f"Config file is: {config.resolve()}") ctx.obj['config'] = config ctx.obj['benchmark_name'] = benchmark.name if benchmark else None
def test_config_file_permission_warn(permission): with set_config_file(permission) as config_file: msg = f"{config_file} is with mode {permission}" with pytest.warns(UserWarning, match=msg): global_config_file = get_global_config_file() assert str(global_config_file) == str(config_file)