Skip to content

Commit

Permalink
fix: fix failing tests (#128)
Browse files Browse the repository at this point in the history
My first intention was to use your library in my production config
handling, to take advantage of classes in the code when reading config
data. (Thank you for your work!)

My issue was that I had "null" values in my yaml file and dataconf
cannot handle them today as far as I've seen. However I removed those
null values and decided to see how I can improve dataconf to handle
null.

To be able to do that first I would like to fix failing unit tests.

I'm working on Win 10, using python 3.9.6.

---------

Co-authored-by: Szeverenyi Zoltan (uif77145) <[email protected]>
Co-authored-by: Teo Stocco <[email protected]>
  • Loading branch information
3 people authored Jan 1, 2024
1 parent 2ee7bfd commit d6e2e3b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dataconf = 'dataconf.cli:run'

[tool.poetry.dependencies]
python = "^3.8"
pyhocon = "0.3.60"
pyhocon = "0.3.59"
python-dateutil = "^2.8.2"
PyYAML = "^6.0.1"
pyparsing = "2.4.7"
Expand Down
19 changes: 12 additions & 7 deletions tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ def test_url(self) -> None:
class A:
url: str

os.environ["p_url"] = "https://github.com/zifeo/dataconf"
assert dataconf.env("p", A) == A(url="https://github.com/zifeo/dataconf")
os.environ.pop("p_url")
os.environ["P_URL"] = "https://github.com/zifeo/dataconf"
assert dataconf.env("P", A) == A(url="https://github.com/zifeo/dataconf")
os.environ.pop("P_URL")

def test_env_var_cast_35(self) -> None:
@dataclass
Expand All @@ -164,16 +164,21 @@ class Example:
hello=None, world="monde", float_num=1.3, int_num=2, bool_var=True
)

def test_dump_fail_54(self):
@pytest.fixture
def named_temporary_file(self):
tfile = tempfile.NamedTemporaryFile(delete=False)
yield tfile
tfile.close()

def test_dump_fail_54(self, named_temporary_file):
@dataclass
class Config:
experiment_name: str

original = Config("test_dump")

with tempfile.NamedTemporaryFile() as f:
dataconf.dump(f.name, original, out="yaml")
validate = dataconf.file(f.name, Config)
dataconf.dump(named_temporary_file.name, original, out="yaml")
validate = dataconf.file(named_temporary_file.name, Config)

assert original == validate

Expand Down

0 comments on commit d6e2e3b

Please sign in to comment.