Skip to content

Commit

Permalink
Update test_json.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-S-Rosen authored Nov 30, 2024
1 parent 4bb8517 commit ad820ce
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
load,
)

from . import __version__ as TESTS_VERSION
from monty import __version__ as TESTS_VERSION

try:
import pandas as pd
Expand Down Expand Up @@ -794,6 +794,18 @@ def test_jsanitize(self):
assert clean_recursive_msonable["hello"][1] == "test"
assert clean_recursive_msonable["test"] == "hi"

DoubleGoodMSONClass = GoodMSONClass(1, 2, 3)
DoubleGoodMSONClass.values = [GoodMSONClass(1, 2, 3)]
clean_recursive_msonable = jsanitize(
DoubleGoodMSONClass, recursive_msonable=True
)
assert clean_recursive_msonable["a"] == 1
assert clean_recursive_msonable["b"] == 2
assert clean_recursive_msonable["c"] == 3
assert clean_recursive_msonable["values"][0]["a"] == 1
assert clean_recursive_msonable["values"][0]["b"] == 2
assert clean_recursive_msonable["values"][0]["c"] == 3

d = {"dt": datetime.datetime.now()}
clean = jsanitize(d)
assert isinstance(clean["dt"], str)
Expand Down

0 comments on commit ad820ce

Please sign in to comment.