Fix a few tests that had collection errors.
This commit is contained in:
parent
f5f6ab0e49
commit
0edb5480f6
@ -19,12 +19,12 @@ TEST_FILES_DIR = py.path.local(_PROJECT).join(_TEST_FILES_DIR)
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def temp_file(tmpdir, request):
|
def temp_file(tmpdir, request):
|
||||||
return _temp_file(tmpdir, request.param)
|
return copy_temp_file(tmpdir, request.param)
|
||||||
|
|
||||||
def _temp_level(tmpdir, filename):
|
def copy_temp_level(tmpdir, filename):
|
||||||
return WorldEditor(_temp_file(tmpdir, filename).strpath)
|
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)
|
source = TEST_FILES_DIR.join(filename)
|
||||||
assert source.exists()
|
assert source.exists()
|
||||||
|
|
||||||
@ -35,17 +35,17 @@ def _temp_file(tmpdir, filename):
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def indev_file(tmpdir):
|
def indev_file(tmpdir):
|
||||||
return _temp_file(tmpdir, "indev.mclevel")
|
return copy_temp_file(tmpdir, "indev.mclevel")
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def pc_world(tmpdir):
|
def pc_world(tmpdir):
|
||||||
return _temp_level(tmpdir, "AnvilWorld")
|
return copy_temp_level(tmpdir, "AnvilWorld")
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(params=["Station.schematic"])
|
@pytest.fixture(params=["Station.schematic"])
|
||||||
def schematic_world(tmpdir, request):
|
def schematic_world(tmpdir, request):
|
||||||
return _temp_level(tmpdir, request.param)
|
return copy_temp_level(tmpdir, request.param)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(params=["AnvilWorld", "Floating.schematic"])
|
@pytest.fixture(params=["AnvilWorld", "Floating.schematic"])
|
||||||
@ -59,4 +59,4 @@ def any_world(tmpdir, request):
|
|||||||
|
|
||||||
# return TempLevel("XXX", createFunc=unpackPocket)
|
# return TempLevel("XXX", createFunc=unpackPocket)
|
||||||
|
|
||||||
return _temp_level(tmpdir, request.param)
|
return copy_temp_level(tmpdir, request.param)
|
@ -25,7 +25,7 @@ def testLoad(indev_file):
|
|||||||
def testLoadUncompressed(self, temp_file):
|
def testLoadUncompressed(self, temp_file):
|
||||||
rootTag = nbt.load(temp_file.strpath)
|
rootTag = nbt.load(temp_file.strpath)
|
||||||
|
|
||||||
@pytest.mark.fixture
|
@pytest.fixture
|
||||||
def created_nbt():
|
def created_nbt():
|
||||||
|
|
||||||
# The root of an NBT file is always a TAG_Compound.
|
# 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"),
|
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")])
|
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
|
""" 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()"""
|
with such a compound, I need to test TAG_Compound.get_all()"""
|
||||||
|
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
from mceditlib.worldeditor import WorldEditor
|
from mceditlib.worldeditor import WorldEditor
|
||||||
from templevel import TempLevel
|
|
||||||
import logging
|
import logging
|
||||||
import numpy
|
import numpy
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
def test_relight():
|
def test_relight(pc_world):
|
||||||
pc_world = TempLevel("AnvilWorld")
|
|
||||||
anvilDim = pc_world.getDimension()
|
anvilDim = pc_world.getDimension()
|
||||||
bounds = anvilDim.bounds
|
bounds = anvilDim.bounds
|
||||||
point = bounds.origin + (bounds.size * (0.5, 0.5, 0.5))
|
point = bounds.origin + (bounds.size * (0.5, 0.5, 0.5))
|
||||||
@ -34,8 +32,7 @@ def test_relight():
|
|||||||
|
|
||||||
pc_world.close()
|
pc_world.close()
|
||||||
|
|
||||||
|
pc_world = WorldEditor(pc_world.filename)
|
||||||
pc_world = WorldEditor(templevel.tmpname)
|
|
||||||
check()
|
check()
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,27 +2,30 @@
|
|||||||
revisionhistory_test
|
revisionhistory_test
|
||||||
"""
|
"""
|
||||||
from mceditlib.revisionhistory import RevisionHistory
|
from mceditlib.revisionhistory import RevisionHistory
|
||||||
from mceditlib.test.templevel import TempFile
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
from .conftest import copy_temp_file
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from mceditlib import nbt
|
from mceditlib import nbt
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def history():
|
def history(tmpdir):
|
||||||
filename = "AnvilWorld"
|
filename = "AnvilWorld"
|
||||||
tmpname = TempFile(filename)
|
tmpname = copy_temp_file(filename)
|
||||||
return RevisionHistory(tmpname)
|
return RevisionHistory(tmpname)
|
||||||
|
|
||||||
|
|
||||||
def readChunkTag(rev, cx, cz):
|
def readChunkTag(rev, cx, cz):
|
||||||
return nbt.load(buf=rev.readChunkBytes(cx, cz, ""))
|
return nbt.load(buf=rev.readChunkBytes(cx, cz, ""))
|
||||||
|
|
||||||
|
|
||||||
def writeChunkTag(rev, cx, cz, tag):
|
def writeChunkTag(rev, cx, cz, tag):
|
||||||
return rev.writeChunkBytes(cx, cz, "", tag.save(compressed=False))
|
return rev.writeChunkBytes(cx, cz, "", tag.save(compressed=False))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user