Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
headtr1ck committed Nov 14, 2024
1 parent 0affb73 commit 66007af
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/test_cdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,18 @@ def test_fromcdl(self):
assert len(f1.dimensions["d"]) == len(f2.dimensions["d"])
assert (f1["ub"][:] == f2["ub"][:]).all()
assert (f1["sb"][:] == f2["sb"][:]).all()

# test if os.PathLike works
with netCDF4.Dataset.fromcdl(pathlib.Path("ubyte.cdl"), ncfilename=pathlib.Path("ubyte3.nc")) as f3:
assert f1.variables.keys() == f3.variables.keys()

# check if correct errors are raised
self.assertRaises(FileNotFoundError, netCDF4.Dataset.fromcdl, "doesnotexist.cdl")
self.assertRaises(FileExistsError, netCDF4.Dataset.fromcdl, "ubyte.cdl", ncfilename="ubyte2.nc")

# cleanup
os.remove("ubyte2.nc")
os.remove("ubyte3.nc")

def tearDown(self):
# Remove the temporary files
Expand Down

0 comments on commit 66007af

Please sign in to comment.