Fix reports test to run under Unit-test and other environments

Originally run correctly only under nose; under unit-test failed
to find anything to do.  Also was selecting wrong test file.
This commit is contained in:
prculley
2017-05-04 10:52:11 -05:00
committed by Nick Hall
parent 2e2e6c88a4
commit 22c966bd8a

View File

@@ -24,21 +24,22 @@ import os
import shutil import shutil
from gramps.test.test_util import Gramps from gramps.test.test_util import Gramps
from gramps.gen.db.utils import open_database
from gramps.gen.user import User from gramps.gen.user import User
from gramps.gen.const import DATA_DIR
ddir = os.path.dirname(__file__) # ddir = os.path.dirname(__file__)
example = os.path.join(ddir, "..", "..", "..", # example = os.path.join(ddir, "..", "..", "..",
"example", "gramps", "data.gramps") # "example", "gramps", "data.gramps")
sample = os.path.join(ddir, "..", "..", "..", # sample = os.path.join(ddir, "..", "..", "..",
"example", "gedcom", "sample.ged") # "example", "gedcom", "sample.ged")
example = os.path.join(DATA_DIR, "tests", "data.gramps")
TREE_NAME = "Test_reporttest" TREE_NAME = "Test_reporttest"
class ReportControl: class ReportControl:
def tearDown(self): def tearDown(self):
out, err = self.call("-y", "--remove", TREE_NAME) out, err = self.call("-y", "--remove", TREE_NAME)
out, err = self.call("-y", "--remove", TREE_NAME + "_import_gedcom") # out, err = self.call("-y", "--remove", TREE_NAME + "_import_gedcom")
def call(self, *args): def call(self, *args):
#print("call:", args) #print("call:", args)
@@ -55,7 +56,7 @@ class ReportControl:
def addreport(self, class_, report_name, test_function, def addreport(self, class_, report_name, test_function,
files, **options): files, **options):
test_name = report_name.replace("-", "_") test_name = "test_" + report_name.replace("-", "_")
setattr(class_, test_name, dynamic_report_method( setattr(class_, test_name, dynamic_report_method(
report_name, report_name,
test_function, test_function,
@@ -68,7 +69,7 @@ class ReportControl:
def addcli(self, class_, report_name, test_function, def addcli(self, class_, report_name, test_function,
files, *args, **options): files, *args, **options):
test_name = report_name.replace("-", "_") test_name = "test_" + report_name.replace("-", "_")
setattr(class_, test_name, setattr(class_, test_name,
dynamic_cli_method( dynamic_cli_method(
report_name, report_name,
@@ -115,7 +116,7 @@ class TestDynamic(unittest.TestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
out, err = cls.call("-y", "--remove", TREE_NAME) out, err = cls.call("-y", "--remove", TREE_NAME)
out, err = cls.call("-y", "--remove", TREE_NAME + "_import_gedcom") # out, err = cls.call("-y", "--remove", TREE_NAME + "_import_gedcom")
reports = ReportControl() reports = ReportControl()