diff --git a/tests/test_mceditlib/conftest.py b/tests/test_mceditlib/conftest.py index 2f8c613..08c604c 100644 --- a/tests/test_mceditlib/conftest.py +++ b/tests/test_mceditlib/conftest.py @@ -19,12 +19,12 @@ TEST_FILES_DIR = py.path.local(_PROJECT).join(_TEST_FILES_DIR) @pytest.fixture def temp_file(tmpdir, request): - return _temp_file(tmpdir, request.param) + return copy_temp_file(tmpdir, request.param) -def _temp_level(tmpdir, filename): - return WorldEditor(_temp_file(tmpdir, filename).strpath) +def copy_temp_level(tmpdir, filename): + return WorldEditor(copy_temp_file(tmpdir, filename).strpath) -def _temp_file(tmpdir, filename): +def copy_temp_file(tmpdir, filename): source = TEST_FILES_DIR.join(filename) assert source.exists() @@ -35,17 +35,17 @@ def _temp_file(tmpdir, filename): @pytest.fixture def indev_file(tmpdir): - return _temp_file(tmpdir, "indev.mclevel") + return copy_temp_file(tmpdir, "indev.mclevel") @pytest.fixture def pc_world(tmpdir): - return _temp_level(tmpdir, "AnvilWorld") + return copy_temp_level(tmpdir, "AnvilWorld") @pytest.fixture(params=["Station.schematic"]) def schematic_world(tmpdir, request): - return _temp_level(tmpdir, request.param) + return copy_temp_level(tmpdir, request.param) @pytest.fixture(params=["AnvilWorld", "Floating.schematic"]) @@ -59,4 +59,4 @@ def any_world(tmpdir, request): # return TempLevel("XXX", createFunc=unpackPocket) - return _temp_level(tmpdir, request.param) \ No newline at end of file + return copy_temp_level(tmpdir, request.param) \ No newline at end of file diff --git a/tests/test_mceditlib/nbt_test.py b/tests/test_mceditlib/nbt_test.py index 6a84200..0dfa27a 100644 --- a/tests/test_mceditlib/nbt_test.py +++ b/tests/test_mceditlib/nbt_test.py @@ -25,7 +25,7 @@ def testLoad(indev_file): def testLoadUncompressed(self, temp_file): rootTag = nbt.load(temp_file.strpath) -@pytest.mark.fixture +@pytest.fixture def created_nbt(): # The root of an NBT file is always a TAG_Compound. @@ -118,7 +118,7 @@ def testModify(created_nbt): level["Entities"][0] = nbt.TAG_Compound([nbt.TAG_String("Creeper", "id"), nbt.TAG_List([nbt.TAG_Double(d) for d in (1, 1, 1)], "Pos")]) -def testMultipleCompound(self): +def testMultipleCompound(): """ According to rumor, some TAG_Compounds store several tags with the same name. Once I find a chunk file with such a compound, I need to test TAG_Compound.get_all()""" diff --git a/tests/test_mceditlib/relight_test.py b/tests/test_mceditlib/relight_test.py index 71c7586..3f3698b 100644 --- a/tests/test_mceditlib/relight_test.py +++ b/tests/test_mceditlib/relight_test.py @@ -1,12 +1,10 @@ from mceditlib.worldeditor import WorldEditor -from templevel import TempLevel import logging import numpy logging.basicConfig(level=logging.INFO) -def test_relight(): - pc_world = TempLevel("AnvilWorld") +def test_relight(pc_world): anvilDim = pc_world.getDimension() bounds = anvilDim.bounds point = bounds.origin + (bounds.size * (0.5, 0.5, 0.5)) @@ -34,8 +32,7 @@ def test_relight(): pc_world.close() - - pc_world = WorldEditor(templevel.tmpname) + pc_world = WorldEditor(pc_world.filename) check() diff --git a/tests/test_mceditlib/revisionhistory_test.py b/tests/test_mceditlib/revisionhistory_test.py index 1e26457..022be33 100644 --- a/tests/test_mceditlib/revisionhistory_test.py +++ b/tests/test_mceditlib/revisionhistory_test.py @@ -2,27 +2,30 @@ revisionhistory_test """ from mceditlib.revisionhistory import RevisionHistory -from mceditlib.test.templevel import TempFile import logging log = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) +from .conftest import copy_temp_file import pytest from mceditlib import nbt + @pytest.fixture -def history(): +def history(tmpdir): filename = "AnvilWorld" - tmpname = TempFile(filename) + tmpname = copy_temp_file(filename) return RevisionHistory(tmpname) + def readChunkTag(rev, cx, cz): return nbt.load(buf=rev.readChunkBytes(cx, cz, "")) + def writeChunkTag(rev, cx, cz, tag): return rev.writeChunkBytes(cx, cz, "", tag.save(compressed=False))