Skip to content

Commit

Permalink
Fixes test_generators.py issue getpelican#3378 for "floating" CWD cap…
Browse files Browse the repository at this point in the history
…ability
  • Loading branch information
egberts committed Jul 24, 2024
1 parent 5b2aaad commit 885f3a2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pelican/tests/test_generators.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os
import sys
from shutil import copy, rmtree
Expand Down Expand Up @@ -1122,14 +1123,21 @@ def test_static_and_attach_links_on_generated_pages(self):
Test to ensure links of the form {static}filename and {attach}filename
are included in context['static_links']
"""
logger = logging.Logger(name=__file__, level=0)
logger.fatal(f"sys.path[0]: {sys.path[0]}")

previous_cwd = os.getcwd()
tests_subdir = os.path.dirname(__file__)
pelican_srcdir = os.path.dirname(tests_subdir)
pelican_pkgdir = os.path.dirname(pelican_srcdir)
testpages_subdir = tests_subdir + os.sep + "TestPages"
page_w_static_links = testpages_subdir + os.sep + "page_with_static_links.md"
settings = get_settings()
settings["PAGE_PATHS"] = [page_w_static_links]
settings["CACHE_PATH"] = self.temp_cache
settings["DEFAULT_DATE"] = (1970, 1, 1)
context = get_context(settings)
os.chdir(pelican_pkgdir)

generator = PagesGenerator(
context=context,
Expand All @@ -1140,8 +1148,9 @@ def test_static_and_attach_links_on_generated_pages(self):
)
generator.generate_context()

self.assertIn("TestPages/image0.jpg", context["static_links"])
self.assertIn("TestPages/image1.jpg", context["static_links"])
self.assertIn("pelican/tests/TestPages/image0.jpg", context["static_links"])
self.assertIn("pelican/tests/TestPages/image1.jpg", context["static_links"])
os.chdir(previous_cwd)


class TestTemplatePagesGenerator(TestCaseWithCLocale):
Expand Down

0 comments on commit 885f3a2

Please sign in to comment.