mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-27 15:25:54 -04:00
tests: Further expand on tools tests
This commit is contained in:
parent
4537540820
commit
3f3819e7fa
@ -2,15 +2,24 @@ import pytest
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
import tempfile
|
||||
import panda3d
|
||||
|
||||
try:
|
||||
panda3d_tools = pytest.importorskip("panda3d_tools")
|
||||
except:
|
||||
panda3d_tools = None
|
||||
|
||||
# Currently only works when Panda was installed from wheel
|
||||
panda3d_tools = pytest.importorskip("panda3d_tools")
|
||||
|
||||
def get_tool(name):
|
||||
if sys.platform == 'win32':
|
||||
name += '.exe'
|
||||
|
||||
tools_dir = os.path.dirname(panda3d_tools.__file__)
|
||||
if panda3d_tools:
|
||||
tools_dir = os.path.dirname(panda3d_tools.__file__)
|
||||
else:
|
||||
tools_dir = os.path.join(os.path.dirname(os.path.dirname(panda3d.__file__)), 'bin')
|
||||
|
||||
path = os.path.join(tools_dir, name)
|
||||
if not os.path.isfile(path):
|
||||
pytest.skip(name + ' not found')
|
||||
@ -24,7 +33,31 @@ def test_bam_info():
|
||||
assert output.startswith(b"This program scans one or more Bam files")
|
||||
|
||||
|
||||
def test_pzip():
|
||||
path = get_tool('pzip')
|
||||
def test_egg_trans():
|
||||
path = get_tool('egg-trans')
|
||||
output = subprocess.check_output([path, '-h'], stderr=subprocess.STDOUT).strip()
|
||||
assert output.startswith(b"This program compresses the named file")
|
||||
assert output.startswith(b"egg-trans reads an egg file and writes")
|
||||
|
||||
|
||||
def test_pzip():
|
||||
data = b'test \000 data'
|
||||
|
||||
try:
|
||||
file = tempfile.NamedTemporaryFile(suffix='.bin', delete=False)
|
||||
file.write(data)
|
||||
file.close()
|
||||
|
||||
path = get_tool('pzip')
|
||||
subprocess.check_output([path, file.name])
|
||||
|
||||
zlib = pytest.importorskip('zlib')
|
||||
|
||||
with open(file.name + '.pz', 'rb') as pz:
|
||||
assert zlib.decompress(pz.read(), 32 + 15, 4096) == data
|
||||
|
||||
finally:
|
||||
if os.path.isfile(file.name):
|
||||
os.remove(file.name)
|
||||
|
||||
if os.path.isfile(file.name + '.pz'):
|
||||
os.remove(file.name + '.pz')
|
||||
|
Loading…
x
Reference in New Issue
Block a user