#1061340 pelican: Please run tests (during build and in an autopkgtest)

Package:
src:pelican
Source:
src:pelican
Submitter:
Louis-Philippe Véronneau
Date:
2024-11-30 15:36:01 UTC
Severity:
normal
Tags:
#1061340#5
Date:
2024-01-22 20:33:34 UTC
From:
To:
Dear maintainers,

This package currently does not run any tests, neither during build nor as autopkgtests. This is pretty bad, as it means the package could be broken without no one realising it! BTS #1057484 is a pretty good example of why it's important to run tests.

I've attached a pretty trivial patch that seems to do 95% of the job. Of course, the last 5% is always the hardest, but from the following error log, it doesn't seem so bad. IMHO, even skipping those failing tests and completely ignoring them would already be an improvement over the current situation.

As for autopkgtests, the magic line to add to d/control is `Testsuite: autopkgtest-pkg-pybuild`.

======================================================================
ERROR: test_theme_overrides (pelican.tests.test_generators.TestGenerator.test_theme_overrides)
Test that the THEME_TEMPLATES_OVERRIDES configuration setting is
----------------------------------------------------------------------
Traceback (most recent call last):
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/tests/test_generators.py", line 148, in test_theme_overrides
     filename = generator.get_template("taglist").filename
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/generators.py", line 127, in get_template
     raise PelicanTemplateNotFound(
pelican.generators.PelicanTemplateNotFound: [templates] unable to load taglist[.html] from ['/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/tests/theme_overrides/level1', '/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/tests/theme_overrides/level2', '/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/themes/simple/templates']

======================================================================
ERROR: test_md_extensions_deprecation (pelican.tests.test_pelican.TestPelican.test_md_extensions_deprecation)
Test that a warning is issued if MD_EXTENSIONS is used
----------------------------------------------------------------------
Traceback (most recent call last):
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/tests/test_pelican.py", line 234, in test_md_extensions_deprecation
     settings = read_settings(
                ^^^^^^^^^^^^^^
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/settings.py", line 213, in read_settings
     settings = configure_settings(settings)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/settings.py", line 575, in configure_settings
     raise Exception(
Exception: You need to specify a path containing the content (see pelican --help for more information)

======================================================================
ERROR: test_theme_static_paths_copy (pelican.tests.test_pelican.TestPelican.test_theme_static_paths_copy)
----------------------------------------------------------------------
Traceback (most recent call last):
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/tests/test_pelican.py", line 162, in test_theme_static_paths_copy
     settings = read_settings(
                ^^^^^^^^^^^^^^
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/settings.py", line 184, in read_settings
     settings = dict(get_settings_from_file(path), **settings)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/settings.py", line 237, in get_settings_from_file
     module = load_source(name, path)
              ^^^^^^^^^^^^^^^^^^^^^^^
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/settings.py", line 19, in load_source
     spec.loader.exec_module(mod)
   File "<frozen importlib._bootstrap_external>", line 990, in exec_module
   File "<frozen importlib._bootstrap_external>", line 1127, in get_code
   File "<frozen importlib._bootstrap_external>", line 1185, in get_data
FileNotFoundError: [Errno 2] No such file or directory: '/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/samples/pelican.conf.py'

======================================================================
ERROR: test_theme_static_paths_copy_single_file (pelican.tests.test_pelican.TestPelican.test_theme_static_paths_copy_single_file)
----------------------------------------------------------------------
Traceback (most recent call last):
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/tests/test_pelican.py", line 188, in test_theme_static_paths_copy_single_file
     settings = read_settings(
                ^^^^^^^^^^^^^^
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/settings.py", line 184, in read_settings
     settings = dict(get_settings_from_file(path), **settings)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/settings.py", line 237, in get_settings_from_file
     module = load_source(name, path)
              ^^^^^^^^^^^^^^^^^^^^^^^
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/settings.py", line 19, in load_source
     spec.loader.exec_module(mod)
   File "<frozen importlib._bootstrap_external>", line 990, in exec_module
   File "<frozen importlib._bootstrap_external>", line 1127, in get_code
   File "<frozen importlib._bootstrap_external>", line 1185, in get_data
FileNotFoundError: [Errno 2] No such file or directory: '/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/samples/pelican.conf.py'

======================================================================
FAIL: test_theme_prefix (pelican.tests.test_generators.TestGenerator.test_theme_prefix)
Test `!theme` theme prefix.
----------------------------------------------------------------------
Traceback (most recent call last):
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/tests/test_generators.py", line 174, in test_theme_prefix
     self.assertEqual(expected_path, os.path.dirname(filename))
AssertionError: '/bui[38 chars]pybuild/cpython3_3.12/build/pelican/themes/notmyidea/templates' != '/bui[38 chars]pybuild/cpython3_3.12/build/pelican/themes/simple/templates'
- /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/themes/notmyidea/templates
?                                                                                      ^^^ ^^^ -
+ /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/themes/simple/templates
?                                                                                      ^^ ^^


======================================================================
FAIL: test_theme_static_paths_dirs (pelican.tests.test_generators.TestStaticGenerator.test_theme_static_paths_dirs)
Test that StaticGenerator properly copies also files mentioned in
----------------------------------------------------------------------
Traceback (most recent call last):
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/tests/test_generators.py", line 1211, in test_theme_static_paths_dirs
     self.assertTrue(os.path.isdir(os.path.join(self.temp_output, "theme/css/")))
AssertionError: False is not true

======================================================================
FAIL: test_theme_static_paths_files (pelican.tests.test_generators.TestStaticGenerator.test_theme_static_paths_files)
Test that StaticGenerator properly copies also files mentioned in
----------------------------------------------------------------------
Traceback (most recent call last):
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/tests/test_generators.py", line 1236, in test_theme_static_paths_files
     self.assertTrue(
AssertionError: False is not true

======================================================================
FAIL: test_log_filter (pelican.tests.test_log.TestLog.test_log_filter)
----------------------------------------------------------------------
Traceback (most recent call last):
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/tests/test_log.py", line 53, in test_log_filter
     self.assertEqual(self.handler.count_logs("Log \\d", logging.WARNING), 0)
AssertionError: 5 != 0

======================================================================
FAIL: test_error_on_warning (pelican.tests.test_testsuite.TestSuiteTest.test_error_on_warning)
----------------------------------------------------------------------
Traceback (most recent call last):
   File "/<<PKGBUILDDIR>>/.pybuild/cpython3_3.12/build/pelican/tests/test_testsuite.py", line 8, in test_error_on_warning
     with self.assertRaises(UserWarning):
AssertionError: UserWarning not raised
----------------------------------------------------------------------
Ran 241 tests in 2.186s

FAILED (failures=5, errors=4, skipped=30)

Cheers,

#1061340#12
Date:
2024-11-30 15:32:30 UTC
From:
To:
Control: tags -1 - patch + help

First off, thanks for packaging python3-watchfiles and fixing my
broken pelican/4.9.1+dfsg-1 upload a while back!

In my latest pelican upload, I've opted to create a short autopkgtest
that takes a simple config file and a markdown blog post (modeled
after some of the input files used by pelican's test suite) that runs
`pelican content` as a quick sanity check [1], which should be
sufficient to avoid having the package break due to missing
dependencies in the future.

I'm leaving this bug open in case anyone wants to go the full mile to
fix and re-enable all of the unit tests in the package. At least some
of the tests (e.g. test_theme_prefix) are failing due to changes made
to the debian package that are not upstreamed (i.e. removing the
notmyidea theme due to not being DFSG distributable); the further the
package diverges from upstream, the more likely these sort of tests
are going to fail, so I'm not really inclined to fix the remaining
tests myself.

Regards,
Vincent

[1] https://salsa.debian.org/python-team/packages/pelican/-/blob/debian/master/debian/tests/generate-content