Fix config tests were dropping a file in cwd
@@ -3,15 +3,13 @@ from click.testing import CliRunner
import wandb, yaml, sys, os, argparse
-@pytest.fixture
-def config():
- return wandb.Config()
-
def init():
os.mkdir(os.getcwd() + "/wandb")
return wandb.Config()
-def test_empty_config(config):
+def test_empty_config():
+ with CliRunner().isolated_filesystem():
+ config = init()
config.foo = 'bar'
assert dict(config)['foo'] == 'bar'
@@ -55,7 +53,7 @@ def test_persist_existing():
config.persist()
assert dict(wandb.Config())['foo'] == 'baz'
-def test_persist_overrides(config):
+def test_persist_overrides():
with CliRunner().isolated_filesystem():
config = init()
config.foo = "bar"
@@ -77,22 +75,29 @@ def test_converts_env():
assert conf.int == 1
del os.environ['WANDB_INT']
-def test_allows_getiter(config):
+def test_allows_getiter():
+ with CliRunner().isolated_filesystem():
+ config = init()
config.foo = "bar"
assert config['foo'] == "bar"
-def test_repr_with_desc(config):
+def test_repr_with_desc():
+ with CliRunner().isolated_filesystem():
+ config = init()
config.foo = "bar"
config.foo_desc = "Fantastic"
assert 'Fantastic' in "%r" % config
-def test_arg_overrides(config):
+def test_arg_overrides():
+ with CliRunner().isolated_filesystem():
+ config = init()
sys.argv = ["cool.py", "--foo=1.0"]
config.foo = "overriden"
config.load_overrides()
assert config.foo == 1.0
def test_str_yaml():
+ with CliRunner().isolated_filesystem():
config = wandb.Config()
config.foo = "bar"
config.foo_desc = "Fantastic"
