Skip to content

Commit 14bb975

Browse files
committed
Added explicit checks that unset fields aren't written
1 parent dd90359 commit 14bb975

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/test_loaders_dumpers/test_dumpers_pydantic.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ def test_yaml_dumper(self):
2929
# test contents of yaml file with cleaned dict made from bookseries instance in setup
3030
with open(self.env.input_path('book_series_lotr.yaml'), 'r') as f:
3131
data = yaml.safe_load(f)
32+
# explicitly confirm that unset fields aren't written to the file
33+
for i in range(3):
34+
'genres' not in data['books'][i].keys()
35+
'inStock' not in data['books'][i].keys()
36+
'creator' not in data['books'][i].keys()
3237
self.assertEqual(data, remove_empty_items(self.bookseries.dict()))
3338

3439

@@ -40,4 +45,9 @@ def test_json_dumper(self):
4045
# test contents of json file with cleaned dict made from bookseries instance in setup
4146
with open(self.env.input_path('book_series_lotr.json'), 'r') as f:
4247
data = json.load(f)
48+
# explicitly confirm that unset fields aren't written to the file
49+
for i in range(3):
50+
'genres' not in data['books'][i].keys()
51+
'inStock' not in data['books'][i].keys()
52+
'creator' not in data['books'][i].keys()
4353
self.assertEqual(data, remove_empty_items(self.bookseries.dict()))

0 commit comments

Comments
 (0)