-
Notifications
You must be signed in to change notification settings - Fork 27
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 failures on windows #206
Fix test failures on windows #206
Conversation
The test failures on Windows (which are not present on Linux) are caused by the test code using simple string compare (through dict) when simulating files. On Windows, paths are formed with "\" instead of "/", which causes inconsistency in the string compare. (Specifically, the "\" were inserted by os.path.join in FluentResourceLoader.)
@eemeli I see you ran ci task and the test job failed. This is a known issue and it is because Python 3.7 reached end of life so it is no longer supported on test:
# Workaround Python 3.7 no longer supported https://github.com/actions/setup-python/issues/962#issuecomment-2414454450
#runs-on: ubuntu-latest
runs-on: ubuntu-22.04 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See inline for a few final simplifications.
My point was that it was the file simulation code that caused the test errors on a different platform, so it makes sense to test the file simulation code.
Adding the tests is fine. I meant that as the existing test_fallback.py
tests end up using the mocking, those tests can only succeed if the mocking works as expected. Therefore, they are also implicitly testing the mocking.
Note: In 457d698, it is my opinionated change to no longer reflect files on disk (code), because it seems unnecessary and unused* in current tests, and may make it difficult when you want to simulate some files don't exist and there are real files which names collide with them. I'd be happy to know what you think about that.
Yeah, dropping that seems like a good idea.
Sorry about being clumsy, this is my first PR.
No worries, welcome to open source! Honestly, if you'd not mentioned that this was your first PR ever, I'd have presumed you to be much more experienced.
I'd be very happy to review further work from you here, or elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution!
The comment was my personal exclamation when learning the code, and now it seems more confusing than helpful. :) It is present in projectfluent#206.
test_fallback.py
uses simple string compare (through dict) to simulate files. On Windows, paths are formed with\
instead of/
, which causes inconsistency in the string compare, producing the failures below. (Specifically, the\
s were created byos.path.join
inFluentResourceLoader
.)Without this fix, running
python -m unittest discover -s fluent.runtime
on Windows on df5ef40 produced the following failures: (Some folders in paths omitted)Note: This pull request has lint errors, but I don't know how to fix them.