pelican-plugins / sitemap

Generates a site map for Pelican-powered sites
50 stars 11 forks source link

test: Fix sitemap test base directory. #37

Closed projectgus closed 1 week ago

projectgus commented 1 week ago

When run with "pdm run invoke test", the CWD is the root of the sitemap plugin (at least on Linux). However, the test case expects to find content in the same directory as the test source file.

Closes #36.

projectgus commented 1 week ago

It looks like when the "CONTENT" directory didn't exist (it was /path/to/sitemap/test_data not /path/to/sitemap/pelican/plugins/sitemap/test_data), Pelican loaded content from its own tests/ directory which I think is why the errors relate to first-article.html generated from here - although I'm not sure why it loaded this file at all, or why it seems to have loaded it twice?

So I don't exactly understand why that behaviour appears, it might be a secondary bug that masked this one?

projectgus commented 1 week ago

I took the liberty of replacing the __file__ reference with the importlib.resources.files Python 3.9+ API.

Oh nice, I did catch myself wondering if there was a more modern way to get this information - and now I know what it is!