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

Pipfile.Updater fails test when trying to delete temporary file before it is closed #54

Open
ptmcg opened this issue Aug 2, 2022 · 0 comments
Assignees

Comments

@ptmcg
Copy link

ptmcg commented Aug 2, 2022

  • Dependency Parser version:
  • Python version: 3.10
  • Operating System: Windows 10

Description

Test failure while trying to os.remove a file that had not yet been closed.

What I Did

While running tests with tox, got the following error:

        data = open(pipfile.name).read()
>       os.remove(pipfile.name)
E       PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\ptmcg\\AppData\\Local\\Temp\\tmpwetzvkjv'

FAILED tests/test_updater.py::test_update_pipfile - PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\ptmcg\\AppData\...

Fixed by changing the "data.open(pipfile.name).read()" line in dparse/updater.py to:

        with open(pipfile.name) as pf:
            data = pf.read()
        pipfile.close()
@yeisonvargasf yeisonvargasf self-assigned this Aug 2, 2022
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

No branches or pull requests

2 participants