diff --git a/src/amulet_nbt/pybind/amulet_nbt.cpp b/src/amulet_nbt/pybind/amulet_nbt.cpp index 58188ad8..3125c136 100644 --- a/src/amulet_nbt/pybind/amulet_nbt.cpp +++ b/src/amulet_nbt/pybind/amulet_nbt.cpp @@ -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") ); diff --git a/tests/test_amulet_nbt/test_metadata.py b/tests/test_amulet_nbt/test_metadata.py new file mode 100644 index 00000000..1457804e --- /dev/null +++ b/tests/test_amulet_nbt/test_metadata.py @@ -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()