-
-
Notifications
You must be signed in to change notification settings - Fork 293
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
A lot of unittests tests fail under Windows due to usage of NamedTemporaryFile #550
Comments
For that specific failure, this commit suggests removing that method entirely. In most other cases, this suggestion to use:
is probably the least impactful targeted workaround. |
There is also now an open PR (python/cpython#22431) to have this python issue 14243 solved in the python tempfile library directly |
I have to admit I'm not a big fan of their solution... (commented). It
means you'd have to use this new parameter everywhere. Maybe to wrap the
contextmanager in a function. Meh.
…On Mon, Oct 5, 2020 at 10:59 AM Chary314 ***@***.***> wrote:
There is also now an open PR to have this python issue 14243
<https://bugs.python.org/issue14243> solved in python tempfile library
directly python/cpython#22431
<python/cpython#22431>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#550 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACSBE5XWEPZYC7YKKHUDSDSJHNLLANCNFSM4Q52IB2Q>
.
|
I think this is a duplicate issue for the previously created one #222 Any way, in python 3.12 there is now new functionality, which allows to re-write the tests in a way that they will work on Windows as well: The tempfile.NamedTemporaryFile function has a new optional parameter delete_on_close ( gh-58451) |
I noticed, that a lot of tests fail under Windows due to usage of NamedTemporaryFile.
e.g.
Most likely it is related to different functionality of NamedTemporaryFile under Linux and Windows
As described here,
NamedTemporaryFile
actually creates and opens the file for you. Unix allows you to open it second time, Windows (starting from NT) apparently not.But I can see in the code, that the usage of NamedTemporaryFile in tests already opens the file, hence operational code does not work later (on Windows)
E.g.:
beancount/utils/text_utils_test.py
and then in operational code
beancount/utils/text_utils.py
Apparently it has been recognized, that it is difficult to write a cross-platform code with NamedTemporaryFile and there is an existing enhancement 14243 for python open since 2012
One of the possible googled solutions is not to use
NamedTemporaryFile
to open the file but only to generate candidate name as described here.This will require however to manually take care of deleting file afterwards, which is in the current code a job of a context manager
The text was updated successfully, but these errors were encountered: