Skip to content

Commit

Permalink
Fixed functions getting paths and added tests (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlegiantJGC authored Aug 5, 2024
1 parent 6ab03b5 commit 71c43a6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/amulet_nbt/pybind/amulet_nbt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ void init_amulet_nbt(py::module& m) {
m.def(
"get_include",
[m, path_join](){
return path_join(m.attr("__path__")[0], py::str("include"));
return path_join(m.attr("__path__").attr("__getitem__")(0), py::str("include"));
},
py::doc("C++ include directory")
);
m.def(
"get_source",
[m, path_join](){
return path_join(m.attr("__path__")[0], py::str("cpp"));
return path_join(m.attr("__path__").attr("__getitem__")(0), py::str("cpp"));
},
py::doc("C++ source directory")
);
Expand Down
19 changes: 19 additions & 0 deletions tests/test_amulet_nbt/test_metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import unittest
import os
import amulet_nbt


class LegacyNBTTests(unittest.TestCase):
def test_version(self) -> None:
self.assertIsInstance(amulet_nbt.__version__, str)
self.assertIsInstance(amulet_nbt.__major__, int)

def test_paths(self) -> None:
self.assertIsInstance(amulet_nbt.get_include(), str)
self.assertIsInstance(amulet_nbt.get_source(), str)
self.assertTrue(os.path.isdir(amulet_nbt.get_include()))
self.assertTrue(os.path.isdir(amulet_nbt.get_source()))


if __name__ == "__main__":
unittest.main()

0 comments on commit 71c43a6

Please sign in to comment.