Skip to content

Commit

Permalink
Added additional tests to test the JSON and YAML dumping features.
Browse files Browse the repository at this point in the history
Updated the project features documentation to include tested and functioning examples based on the latest core design.
  • Loading branch information
AzorianMatt committed Feb 1, 2024
1 parent 079eca5 commit 94ab5d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/wiki/project/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ assert isinstance(r.str, str) # True
assert isinstance(r.int, int) # True
assert isinstance(r.float, float) # True
assert isinstance(r.complex, complex) # True
assert isinstance(r.bool, bool) # True
assert isinstance(r.none, type(None)) # True
assert isinstance(r.bool().ref, bool) # True
assert isinstance(r.none().ref, type(None)) # True
assert isinstance(r.dict, dict) # True
assert isinstance(r.list, list) # True
assert isinstance(r.tuple, tuple) # True
Expand Down Expand Up @@ -333,7 +333,7 @@ print( r.dict('a') ) # 1
print( r.dict.b ) # 123.456
print( type(r.dict.b) ) # <class 'reflective.types.numeric.RFloat'>
print( r.dict.a('/reference') ) # 1
print( r.dict.a('/reference').raw ) # $r{/dict/a}
print( r.dict.a('/reference')().raw ) # $r{/dict/a}
```

#### Environment Variable References
Expand Down
15 changes: 15 additions & 0 deletions src/tests/test_dumps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from reflective import Reflective


def test_json():
r = Reflective({'key': 'value'})

assert r().to_json(flat=True) == '{"key": "value"}'
assert r().json == '{"key": "value"}'


def test_yaml():
r = Reflective({'key': 'value'})

assert r().to_yaml() == 'key: value\n'
assert r().yaml == 'key: value\n'

0 comments on commit 94ab5d2

Please sign in to comment.