Running all tests reports a couple of errors and a bunch of failures (“FAILED (failures=433, errors=2, skipped=56)FAILED (failures=433, errors=2, skipped=56)”). Looking only at the the two errors first, this is the error output:
======================================================================
ERROR: test_ancestor_chart (gramps.plugins.test.reports_test.TestDynamic)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/hgohel/dev/gramps/gramps/plugins/test/reports_test.py", line 93, in test_method
self.assertTrue(test_function(out, err, report_name, **options))
File "/home/hgohel/dev/gramps/gramps/plugins/test/reports_test.py", line 171, in test_output_file
raise Exception("can't find '%s' in order to delete it" % filename)
Exception: can't find 'ancestor_chart-2.svg' in order to delete it
======================================================================
ERROR: test_timeline (gramps.plugins.test.reports_test.TestDynamic)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/hgohel/dev/gramps/gramps/plugins/test/reports_test.py", line 93, in test_method
self.assertTrue(test_function(out, err, report_name, **options))
File "/home/hgohel/dev/gramps/gramps/plugins/test/reports_test.py", line 171, in test_output_file
raise Exception("can't find '%s' in order to delete it" % filename)
Exception: can't find 'timeline-2.svg' in order to delete it
The code that generates and runs these tests is in test_reports.py.
The exception is saying it can’t find ‘ancestor_chart-2.svg’ in order to delete it and I’m not quite following why the test expects to generate multiple copies of the report as listed in the list of files. Running the test once should generate only one output file, ‘ancestor_chart.svg’ which I think is happening.
Tagging @dsblank based on file history; any insight would be appreciated! Also, is anyone else able to replicate these errors running tests locally?
No, I don’t have any insight into that error. If I was going to take a wild stab in the dark, I’d guess that the SVG wasn’t created (because of some limitation of the environment) and therefore can’t be deleted. But only guessing. (I haven’t used Windows (or Mac) since 1997 so I can’t help much more).
Thanks for the quick reply! I don’t think this has anything to do with WSL or Windows, but who knows.
Yes, definitely ‘ancestor_chart-2.svg’ through -6 aren’t generated. And based on the test running once should have generated only ‘ancestor_chart.svg’ so I can see why it’s failing. But it feels like I’m missing something that would make it generate the others…
Tracked this down! The discrepancy is in expectation of report options when running te tests.
When I build and run the code from Git with no other local installation of Gramps, default settings are used for everything. Turns out that the default report settings are set to paper size A0 and orientation Landscape paper which generated only one file for the output, while the UT expected six.
I ran Gramps, changed the report settings to use Letter which generated four. Next I set it to Letter and Portrait mode which generated the six files expected and the UT passed.
It’s not clear to me why these tests don’t fail on the CI system, but one way to ensure that they work in any environment would be explicitly specify paper options for the report e.g. “papero=0,papers=Letter” and that seemed to work:
def dynamic_report_method(report_name, test_function, files, *args, **options):
args = list(args)
args[-1] += "," + (",".join(["%s=%s" % (k, v) for (k, v) in options.items()]))
args[-1] += ",papero=0,papers=Letter," ### <<<< ADDED THESE OPTIONS
options["files"] = files
def test_method(self): # This needs to have "test" in name
out, err = self.call(*args)
self.assertTrue(test_function(out, err, report_name, **options))
return test_method
Still not clear how these tests are passing in other environments without this change.