Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test_generators.py, for floating CWD #3379

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion 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,11 +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"] = ["TestPages/page_with_static_links.md"]
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 @@ -1139,6 +1150,7 @@ def test_static_and_attach_links_on_generated_pages(self):

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