From f0ebe5e28d4212788791b1c62749ba0ef0a126ba Mon Sep 17 00:00:00 2001 From: gentlegiantJGC Date: Wed, 21 Feb 2024 08:50:28 +0000 Subject: [PATCH 1/4] Remove editable install when unit testing This will test it how it is actually used --- .github/workflows/python-unittests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-unittests.yml b/.github/workflows/python-unittests.yml index 49648281..29615b9e 100644 --- a/.github/workflows/python-unittests.yml +++ b/.github/workflows/python-unittests.yml @@ -28,6 +28,6 @@ jobs: shell: bash run: | python -m pip install --upgrade pip - pip install -e .[dev] + pip install .[dev] - name: Test with unittest run: python -m unittest discover -v -s tests From 71c38cd9b28522cdf115d0d568cd5c06fc674569 Mon Sep 17 00:00:00 2001 From: gentlegiantJGC Date: Wed, 21 Feb 2024 08:50:36 +0000 Subject: [PATCH 2/4] Added missing init file --- src/amulet_nbt/_nbt_encoding/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/amulet_nbt/_nbt_encoding/__init__.py diff --git a/src/amulet_nbt/_nbt_encoding/__init__.py b/src/amulet_nbt/_nbt_encoding/__init__.py new file mode 100644 index 00000000..e69de29b From a7a46585bc2e4a3e4095de1b59e60e2d1d4f9bcf Mon Sep 17 00:00:00 2001 From: gentlegiantJGC Date: Wed, 21 Feb 2024 08:51:12 +0000 Subject: [PATCH 3/4] Remove carriage return This seemed to be writing \r\r\n --- src/amulet_nbt/_nbt_encoding/_string/_cpp/write_snbt.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/amulet_nbt/_nbt_encoding/_string/_cpp/write_snbt.hpp b/src/amulet_nbt/_nbt_encoding/_string/_cpp/write_snbt.hpp index 5bfe24bc..d0724ecb 100644 --- a/src/amulet_nbt/_nbt_encoding/_string/_cpp/write_snbt.hpp +++ b/src/amulet_nbt/_nbt_encoding/_string/_cpp/write_snbt.hpp @@ -220,7 +220,7 @@ void write_snbt_list(std::string& snbt, const CListTagPtr& tag, const std::strin const std::vector& list = std::get>(*tag); snbt.append("["); for (size_t i = 0; i < list.size(); i++){ - snbt.append("\r\n"); + snbt.append("\n"); write_indent(snbt, indent, indent_count + 1); if constexpr (std::is_same_v){write_byte_snbt(snbt, list[i]);} else if constexpr (std::is_same_v){write_short_snbt(snbt, list[i]);} else @@ -235,7 +235,7 @@ void write_snbt_list(std::string& snbt, const CListTagPtr& tag, const std::strin if constexpr (std::is_same_v){write_int_array_snbt(snbt, list[i]);} else if constexpr (std::is_same_v){write_long_array_snbt(snbt, list[i]);} if (i + 1 == list.size()){ - snbt.append("\r\n"); + snbt.append("\n"); write_indent(snbt, indent, indent_count); } else { snbt.append(","); @@ -331,13 +331,13 @@ void write_compound_snbt(std::string& snbt, const CCompoundTagPtr& tag, const st auto sorted = sort_compound(tag); snbt.append("{"); for (auto it = sorted.begin(); it != sorted.end(); it++){ - snbt.append("\r\n"); + snbt.append("\n"); write_indent(snbt, indent, indent_count + 1); write_key(snbt, it->first); snbt.append(": "); write_node_snbt(snbt, it->second, indent, indent_count + 1); if (std::next(it) == sorted.end()){ - snbt.append("\r\n"); + snbt.append("\n"); write_indent(snbt, indent, indent_count); } else { snbt.append(","); From ffd984425369c8e3ca977b1f597de3058d705f23 Mon Sep 17 00:00:00 2001 From: gentlegiantJGC Date: Wed, 21 Feb 2024 09:15:06 +0000 Subject: [PATCH 4/4] Updated tests --- .../test_amulet_nbt/test_tag/test_compound.py | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/tests/test_amulet_nbt/test_tag/test_compound.py b/tests/test_amulet_nbt/test_tag/test_compound.py index 7b22d32e..ea00d6e6 100644 --- a/tests/test_amulet_nbt/test_tag/test_compound.py +++ b/tests/test_amulet_nbt/test_tag/test_compound.py @@ -777,53 +777,53 @@ def test_to_snbt(self): full_compound.to_snbt(None), ) self.assertEqual( - "{\r\n" - " byte: 0b,\r\n" - " byte_array: [B;],\r\n" - " compound: {},\r\n" - " double: 0d,\r\n" - " float: 0f,\r\n" - " int: 0,\r\n" - " int_array: [I;],\r\n" - " list: [],\r\n" - " long: 0L,\r\n" - " long_array: [L;],\r\n" - " short: 0s,\r\n" - ' string: ""\r\n' + "{\n" + " byte: 0b,\n" + " byte_array: [B;],\n" + " compound: {},\n" + " double: 0d,\n" + " float: 0f,\n" + " int: 0,\n" + " int_array: [I;],\n" + " list: [],\n" + " long: 0L,\n" + " long_array: [L;],\n" + " short: 0s,\n" + ' string: ""\n' "}", full_compound.to_snbt(" "), ) self.assertEqual( - "{\r\n" - " byte: 0b,\r\n" - " byte_array: [B;],\r\n" - " compound: {},\r\n" - " double: 0d,\r\n" - " float: 0f,\r\n" - " int: 0,\r\n" - " int_array: [I;],\r\n" - " list: [],\r\n" - " long: 0L,\r\n" - " long_array: [L;],\r\n" - " short: 0s,\r\n" - ' string: ""\r\n' + "{\n" + " byte: 0b,\n" + " byte_array: [B;],\n" + " compound: {},\n" + " double: 0d,\n" + " float: 0f,\n" + " int: 0,\n" + " int_array: [I;],\n" + " list: [],\n" + " long: 0L,\n" + " long_array: [L;],\n" + " short: 0s,\n" + ' string: ""\n' "}", full_compound.to_snbt(4), ) self.assertEqual( - "{\r\n" - "\tbyte: 0b,\r\n" - "\tbyte_array: [B;],\r\n" - "\tcompound: {},\r\n" - "\tdouble: 0d,\r\n" - "\tfloat: 0f,\r\n" - "\tint: 0,\r\n" - "\tint_array: [I;],\r\n" - "\tlist: [],\r\n" - "\tlong: 0L,\r\n" - "\tlong_array: [L;],\r\n" - "\tshort: 0s,\r\n" - '\tstring: ""\r\n' + "{\n" + "\tbyte: 0b,\n" + "\tbyte_array: [B;],\n" + "\tcompound: {},\n" + "\tdouble: 0d,\n" + "\tfloat: 0f,\n" + "\tint: 0,\n" + "\tint_array: [I;],\n" + "\tlist: [],\n" + "\tlong: 0L,\n" + "\tlong_array: [L;],\n" + "\tshort: 0s,\n" + '\tstring: ""\n' "}", full_compound.to_snbt("\t"), )