diff --git a/test/cone.deck b/test/cone.deck index 17ee7b3..916956f 100644 --- a/test/cone.deck +++ b/test/cone.deck @@ -121,8 +121,10 @@ begin:dist_fn resolution1 = 1 resolution2 = 100 - include_species:electron - include_species:proton + include_species:Electron + include_species:Proton + + identify:Photon end:dist_fn @@ -145,6 +147,8 @@ begin:dist_fn resolution2 = 100 resolution3 = 100 - include_species:electron - include_species:proton + include_species:Electron + include_species:Proton + + identify:Photon end:dist_fn diff --git a/test/test_read.py b/test/test_read.py index 04b3df0..a58e128 100644 --- a/test/test_read.py +++ b/test/test_read.py @@ -1,4 +1,4 @@ -from epydeck import loads, load +import epydeck import pathlib @@ -15,7 +15,7 @@ def test_basic_block(): end:block """ - data = loads(text) + data = epydeck.loads(text) expected = { "block": { @@ -41,7 +41,7 @@ def test_repeated_line(): end:block """ - data = loads(text) + data = epydeck.loads(text) expected = {"block": {"a": 1, "b": 2, "c": [3, 4]}} @@ -65,7 +65,7 @@ def test_repeated_block(): end:block """ - data = loads(text) + data = epydeck.loads(text) expected = { "block": { @@ -81,14 +81,30 @@ def test_include_species(): text = """ begin:dist_fn a = 1 - include_species: electron - include_species: proton + include_species:Electron + include_species:Proton end:dist_fn """ - data = loads(text) + data = epydeck.loads(text) - expected = {"dist_fn": {"a": 1, "include_species": ["electron", "proton"]}} + expected = {"dist_fn": {"a": 1, "include_species": ["Electron", "Proton"]}} + + assert expected == data + + +def test_include_identify(): + text = """ + begin:dist_fn + a = 1 + identify:Electron + identify:Proton + end:dist_fn + """ + + data = epydeck.loads(text) + + expected = {"dist_fn": {"a": 1, "identify": ["Electron", "Proton"]}} assert expected == data @@ -97,7 +113,7 @@ def test_read_file(): filename = pathlib.Path(__file__).parent / "cone.deck" with open(filename) as f: - data = load(f) + data = epydeck.load(f) assert "control" in data assert "species" in data diff --git a/test/test_write.py b/test/test_write.py index 13c59b8..5ad60ac 100644 --- a/test/test_write.py +++ b/test/test_write.py @@ -1,5 +1,4 @@ -from epydeck import dumps, dump, load - +import epydeck from textwrap import dedent @@ -28,7 +27,7 @@ def test_basic_block(): "f": True, } } - result = dumps(deck) + result = epydeck.dumps(deck) assert expected == result @@ -47,7 +46,7 @@ def test_repeated_line(): ) deck = {"block": {"a": 1, "b": 2, "c": [3, 4]}} - result = dumps(deck) + result = epydeck.dumps(deck) assert expected == result @@ -78,7 +77,7 @@ def test_repeated_block(): "second": {"name": "second", "a": 4, "b": 5, "c": 6}, } } - result = dumps(deck) + result = epydeck.dumps(deck) assert expected == result @@ -88,15 +87,33 @@ def test_include_species(): """\ begin:dist_fn a = 1 - include_species: electron - include_species: proton + include_species:Electron + include_species:Proton + end:dist_fn + + """ + ) + + deck = {"dist_fn": {"a": 1, "include_species": ["Electron", "Proton"]}} + result = epydeck.dumps(deck) + + assert expected == result + + +def test_include_identify(): + expected = dedent( + """\ + begin:dist_fn + a = 1 + identify:Electron + identify:Proton end:dist_fn """ ) - deck = {"dist_fn": {"a": 1, "include_species": ["electron", "proton"]}} - result = dumps(deck) + deck = {"dist_fn": {"a": 1, "identify": ["Electron", "Proton"]}} + result = epydeck.dumps(deck) assert expected == result @@ -119,9 +136,9 @@ def test_write_to_file(tmp_path): filename = tmp_path / "test.in" with open(filename, "w") as f: - dump(deck, f) + epydeck.dump(deck, f) with open(filename, "r") as f: - data = load(f) + data = epydeck.load(f) assert data == deck