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

test: Fix sitemap test base directory. #37

Merged
merged 2 commits into from
Nov 4, 2024

Conversation

projectgus
Copy link
Contributor

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
Copy link
Contributor Author

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 and others added 2 commits November 4, 2024 17:02
When run with "pdm run invoke test", the CWD is the root of the sitemap
plugin. However, the test case expects to find content in the same
directory as the test source file.
Copy link
Contributor

@justinmayer justinmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks, Angus! Interesting… I'm not sure about the questions you raised, but it seems that you have found a solution that will suit our needs for the moment.

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

Thanks again for your help. Much appreciated! 🏅

@justinmayer justinmayer merged commit 89f32c2 into pelican-plugins:main Nov 4, 2024
7 checks passed
@projectgus
Copy link
Contributor Author

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!

@projectgus projectgus deleted the bugfix/sitemap_tests branch November 4, 2024 22:32
projectgus added a commit to projectgus/sitemap that referenced this pull request Nov 10, 2024
Follow-up to 3186431, as per comment here:
pelican-plugins#37 (comment)

- CONTENT key is unused
- PATH key determines the content path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sitemap plugin test errors in CI
2 participants