mirror of https://github.com/CIRCL/PyCIRCLean
Added fixtures for source and dest in test_examples
parent
516b14ca10
commit
67e825046d
|
@ -6,78 +6,85 @@ import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from bin.specific import KittenGroomerSpec
|
from PyCIRCLean.bin.specific import KittenGroomerSpec
|
||||||
from bin.pier9 import KittenGroomerPier9
|
from PyCIRCLean.bin.pier9 import KittenGroomerPier9
|
||||||
from bin.generic import KittenGroomer
|
from PyCIRCLean.bin.generic import KittenGroomer
|
||||||
|
|
||||||
if sys.version_info.major == 2:
|
if sys.version_info.major == 2:
|
||||||
from bin.filecheck import KittenGroomerFileCheck
|
from PyCIRCLean.bin.filecheck import KittenGroomerFileCheck
|
||||||
|
|
||||||
|
|
||||||
def setup_module():
|
skip = pytest.mark.skip
|
||||||
PY3 = sys.version_info.major == 3
|
py2_only = pytest.mark.skipif(sys.version_info.major == 3,
|
||||||
CURPATH = os.getcwd()
|
reason="filecheck.py only runs on python 2")
|
||||||
|
|
||||||
|
|
||||||
def test_specific_valid(self):
|
@pytest.fixture
|
||||||
src = os.path.join(CURPATH, 'tests/src2')
|
def src_simple():
|
||||||
dst = os.path.join(CURPATH, 'tests/dst')
|
return os.path.join(os.getcwd(), 'tests/src_simple')
|
||||||
spec = KittenGroomerSpec(src, dst, debug=True)
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def src_complex():
|
||||||
|
return os.path.join(os.getcwd(), 'tests/src_complex')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def dst():
|
||||||
|
return os.path.join(os.getcwd(), 'tests/dst')
|
||||||
|
|
||||||
|
|
||||||
|
def test_specific_valid(src_simple, dst):
|
||||||
|
spec = KittenGroomerSpec(src_simple, dst, debug=True)
|
||||||
spec.processdir()
|
spec.processdir()
|
||||||
self.dump_logs(spec)
|
dump_logs(spec)
|
||||||
|
|
||||||
def test_specific_invalid(self):
|
|
||||||
src = os.path.join(CURPATH, 'tests/src')
|
|
||||||
dst = os.path.join(CURPATH, 'tests/dst')
|
|
||||||
spec = KittenGroomerSpec(src, dst, debug=True)
|
|
||||||
spec.processdir()
|
|
||||||
self.dump_logs(spec)
|
|
||||||
|
|
||||||
def test_pier9(self):
|
def test_specific_invalid(src_complex, dst):
|
||||||
src = os.path.join(CURPATH, 'tests/src')
|
spec = KittenGroomerSpec(src_complex, dst, debug=True)
|
||||||
dst = os.path.join(CURPATH, 'tests/dst')
|
|
||||||
spec = KittenGroomerPier9(src, dst, debug=True)
|
|
||||||
spec.processdir()
|
spec.processdir()
|
||||||
self.dump_logs(spec)
|
dump_logs(spec)
|
||||||
|
|
||||||
def test_generic(self):
|
|
||||||
src = os.path.join(CURPATH, 'tests/src2')
|
|
||||||
dst = os.path.join(CURPATH, 'tests/dst')
|
|
||||||
spec = KittenGroomer(src, dst, debug=True)
|
|
||||||
spec.processdir()
|
|
||||||
self.dump_logs(spec)
|
|
||||||
|
|
||||||
def test_generic_2(self):
|
def test_pier9(src_complex, dst):
|
||||||
src = os.path.join(CURPATH, 'tests/src')
|
spec = KittenGroomerPier9(src_complex, dst, debug=True)
|
||||||
dst = os.path.join(CURPATH, 'tests/dst')
|
|
||||||
spec = KittenGroomer(src, dst, debug=True)
|
|
||||||
spec.processdir()
|
spec.processdir()
|
||||||
self.dump_logs(spec)
|
dump_logs(spec)
|
||||||
|
|
||||||
def test_filecheck(self):
|
|
||||||
if PY3:
|
|
||||||
return
|
|
||||||
src = os.path.join(CURPATH, 'tests/src')
|
|
||||||
dst = os.path.join(CURPATH, 'tests/dst')
|
|
||||||
spec = KittenGroomerFileCheck(src, dst, debug=True)
|
|
||||||
spec.processdir()
|
|
||||||
self.dump_logs(spec)
|
|
||||||
|
|
||||||
def test_filecheck_2(self):
|
@skip
|
||||||
if PY3:
|
def test_generic(src_simple, dst):
|
||||||
return
|
spec = KittenGroomer(src_simple, dst, debug=True)
|
||||||
src = os.path.join(self.CURPATH, 'tests/src2')
|
|
||||||
dst = os.path.join(self.CURPATH, 'tests/dst')
|
|
||||||
spec = KittenGroomerFileCheck(src, dst, debug=True)
|
|
||||||
spec.processdir()
|
spec.processdir()
|
||||||
self.dump_logs(spec)
|
dump_logs(spec)
|
||||||
|
|
||||||
|
|
||||||
|
@skip
|
||||||
|
def test_generic_2(src_complex, dst):
|
||||||
|
spec = KittenGroomer(src_complex, dst, debug=True)
|
||||||
|
spec.processdir()
|
||||||
|
dump_logs(spec)
|
||||||
|
|
||||||
|
|
||||||
|
@py2_only
|
||||||
|
def test_filecheck(src_complex, dst):
|
||||||
|
spec = KittenGroomerFileCheck(src_complex, dst, debug=True)
|
||||||
|
spec.processdir()
|
||||||
|
dump_logs(spec)
|
||||||
|
|
||||||
|
|
||||||
|
@py2_only
|
||||||
|
def test_filecheck_2(src_simple, dst):
|
||||||
|
spec = KittenGroomerFileCheck(src_simple, dst, debug=True)
|
||||||
|
spec.processdir()
|
||||||
|
dump_logs(spec)
|
||||||
|
|
||||||
## Helper functions
|
## Helper functions
|
||||||
|
|
||||||
def dump_logs(self, kg):
|
def dump_logs(spec):
|
||||||
print(open(kg.log_processing, 'rb').read())
|
print(open(spec.log_processing, 'rb').read())
|
||||||
if kg.debug:
|
if spec.debug:
|
||||||
if os.path.exists(kg.log_debug_err):
|
if os.path.exists(spec.log_debug_err):
|
||||||
print(open(kg.log_debug_err, 'rb').read())
|
print(open(spec.log_debug_err, 'rb').read())
|
||||||
if os.path.exists(kg.log_debug_out):
|
if os.path.exists(spec.log_debug_out):
|
||||||
print(open(kg.log_debug_out, 'rb').read())
|
print(open(spec.log_debug_out, 'rb').read())
|
||||||
|
|
|
@ -16,13 +16,6 @@ def test_base():
|
||||||
assert kg.main
|
assert kg.main
|
||||||
|
|
||||||
|
|
||||||
def test_specific():
|
|
||||||
src = os.path.join(PATH, 'src2')
|
|
||||||
dst = os.path.join(PATH, 'dst')
|
|
||||||
spec = specific.KittenGroomerSpec(src, dst, debug=True)
|
|
||||||
spec.processdir()
|
|
||||||
|
|
||||||
|
|
||||||
def test_help_file():
|
def test_help_file():
|
||||||
f = FileBase('tests/src/blah.conf', 'tests/dst/blah.conf')
|
f = FileBase('tests/src/blah.conf', 'tests/dst/blah.conf')
|
||||||
f.make_unknown()
|
f.make_unknown()
|
||||||
|
|
Loading…
Reference in New Issue