Andreas Tille pushed to branch master at Debian Med / q2cli


Commits:
c52587b3 by Andreas Tille at 2026-11-17T09:28:24+01:00
Skip the make-report tests when q2templates lacks reports support

The make-report command imports q2templates.reports before it validates
its arguments, and q2templates releases before 2026.10 do not provide
that subpackage at all.  On such a version test_make_report_success and
test_make_report_duplicate_names both died with ModuleNotFoundError
inside CliRunner before reaching their assertion, which made the
build-time test suite fail with an empty result.output.

Guard the duplicate-name test on the availability of the reports module
and keep the stricter matryoshka assets check for the test that actually
builds a report.  Upstream builds, which have both, still run them.

Reported against a pbuilder environment that resolved q2templates from
unstable (2024.5.0+ds-4) rather than the 2026.10 package.

Assisted-By: aim2balance/a2b-code

- - - - -


1 changed file:

- debian/patches/skip-make-report-test.patch


Changes:

=====================================
debian/patches/skip-make-report-test.patch
=====================================
@@ -1,28 +1,52 @@
-Description: skip the make-report test when the matryoshka assets are absent
- q2templates generates its ``built_assets/matryoshka`` report assets at
- build time with npm (``make build-reports``).  They are intentionally not
- included in the Debian q2templates package, so
- TestMakeReport.test_make_report_success cannot succeed in Debian.  Skip it
- when the assets are not installed (upstream builds still run it).
+Description: skip the make-report tests when their requirements are absent
+ The ``make-report`` command imports ``q2templates.reports`` before it
+ validates its arguments, and q2templates releases before 2026.10 do not
+ provide that subpackage at all, so both make-report tests crash with
+ ModuleNotFoundError there before reaching their assertion.  Guard them
+ with a check for the module.
+
+ q2templates also generates its ``built_assets/matryoshka`` report assets
+ at build time with npm (``make build-reports``).  They are intentionally
+ not included in the Debian q2templates package, so the test that actually
+ builds a report cannot succeed and needs the stricter assets check.
+
+ Upstream builds, which have the module and the assets, still run both
+ tests.
 Author: Andreas Tille <[email protected]>
 Forwarded: not-needed
-Last-Update: 2026-11-16
+Last-Update: 2026-11-17
 Assisted-By: aim2balance/a2b-code
 
 --- a/rachis_cli/tests/test_tools.py
 +++ b/rachis_cli/tests/test_tools.py
-@@ -34,6 +34,23 @@ from rachis_cli.commands import RootCommand
+@@ -34,6 +34,39 @@ from rachis_cli.commands import RootCommand
  from rachis_cli.core.usage import ReplayCLIUsage
  
  
++def _q2templates_reports_available():
++    """Return True when q2templates provides the reports module.
++
++    ``make-report`` imports ``q2templates.reports`` before it validates its
++    arguments, so both make-report tests need that subpackage.  q2templates
++    releases before 2026.10 do not provide it at all.
++    """
++    try:
++        import importlib.util
++        return importlib.util.find_spec('q2templates.reports') is not None
++    except ImportError:
++        return False
++
++
 +def _matryoshka_assets_available():
 +    """Return True when the generated matryoshka report assets are installed.
 +
 +    q2templates builds the ``built_assets/matryoshka`` reports with npm
 +    (``make build-reports``), so they are intentionally not part of the
-+    corresponding Debian package.  The make-report test can only run when
-+    they are present.
++    corresponding Debian package.  The test that builds a report can only
++    run when they are present.
 +    """
++    if not _q2templates_reports_available():
++        return False
 +    try:
 +        import importlib.resources
 +        importlib.resources.files(
@@ -35,12 +59,21 @@ Assisted-By: aim2balance/a2b-code
  class TestCastMetadata(unittest.TestCase):
      def setUp(self):
          self.runner = CliRunner()
-@@ -2039,6 +2056,8 @@ class TestMakeReport(unittest.TestCase):
+@@ -2039,6 +2072,8 @@ class TestMakeReport(unittest.TestCase):
      def tearDown(self):
          shutil.rmtree(self.tempdir)
  
 +    @unittest.skipUnless(_matryoshka_assets_available(),
-+                         'q2templates matryoshka assets not installed')
++                         'q2templates reports support not available')
      def test_make_report_success(self):
          report = os.path.join(self.tempdir, 'report.qzv')
          result = self.runner.invoke(
+@@ -2050,6 +2085,8 @@ class TestMakeReport(unittest.TestCase):
+         # ensure the report file was written and is a zip archive
+         self.assertTrue(zipfile.is_zipfile(report))
+ 
++    @unittest.skipUnless(_q2templates_reports_available(),
++                         'q2templates reports support not available')
+     def test_make_report_duplicate_names(self):
+         # create two visualizations that share the same filename but live in
+         # different directories to trigger the duplicate-name error



View it on GitLab: 
https://salsa.debian.org/med-team/q2cli/-/commit/c52587b315404700b5e813afc9e65bbf88518a61

-- 
View it on GitLab: 
https://salsa.debian.org/med-team/q2cli/-/commit/c52587b315404700b5e813afc9e65bbf88518a61
You're receiving this email because of your account on salsa.debian.org. Manage 
all notifications: https://salsa.debian.org/-/profile/notifications | Help: 
https://salsa.debian.org/help


_______________________________________________
debian-med-commit mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/debian-med-commit

Reply via email to