getnikola / nikola

A static website and blog generator
https://getnikola.com/
MIT License
2.6k stars 444 forks source link

Fix chdir leaking on error out of cd-contextmanager of tests/helper.py. #3720

Closed aknrdureegaesr closed 9 months ago

aknrdureegaesr commented 9 months ago

Pull Request Checklist

Description

While working on something else, I happened to spot a bug in tests/helper.py: The change of directory can (unintentionally) leak out of the cd context manager if the code inside the context throws an exception. In other words, on error, the change of directory is not undone.

I added a test for the test helper that demonstrates the bug if run with the previous test helper code. Not sure whether you want that.

This is a rather trivial change not visible to the end-user, so there is no need to add to CHANGELOG.

I plead guilty not having created a separate bug issue first. Do you need it in such a trivial case?

Kwpolska commented 9 months ago

I plead guilty not having created a separate bug issue first. Do you need it in such a trivial case?

Not really.

Thanks for fixing this!