Skip to content

Commit 66007af

Browse files
committed
add tests
1 parent 0affb73 commit 66007af

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/test_cdl.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,18 @@ def test_fromcdl(self):
6868
assert len(f1.dimensions["d"]) == len(f2.dimensions["d"])
6969
assert (f1["ub"][:] == f2["ub"][:]).all()
7070
assert (f1["sb"][:] == f2["sb"][:]).all()
71+
72+
# test if os.PathLike works
73+
with netCDF4.Dataset.fromcdl(pathlib.Path("ubyte.cdl"), ncfilename=pathlib.Path("ubyte3.nc")) as f3:
74+
assert f1.variables.keys() == f3.variables.keys()
7175

76+
# check if correct errors are raised
77+
self.assertRaises(FileNotFoundError, netCDF4.Dataset.fromcdl, "doesnotexist.cdl")
78+
self.assertRaises(FileExistsError, netCDF4.Dataset.fromcdl, "ubyte.cdl", ncfilename="ubyte2.nc")
79+
80+
# cleanup
7281
os.remove("ubyte2.nc")
82+
os.remove("ubyte3.nc")
7383

7484
def tearDown(self):
7585
# Remove the temporary files

0 commit comments

Comments
 (0)