Skip to content

Getting ResourceWarning: unclosed file open(csspath) #246

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

Closed
wanam opened this issue Oct 18, 2019 · 8 comments
Closed

Getting ResourceWarning: unclosed file open(csspath) #246

wanam opened this issue Oct 18, 2019 · 8 comments

Comments

@wanam
Copy link
Contributor

wanam commented Oct 18, 2019

I'm getting bellow error while loading a custom css file:
ResourceWarning: unclosed file <_io.TextIOWrapper name='assets/style.css' mode='r' encoding='UTF-8'>open(csspath)

The bug is similar to pytest-dev/pytest#4355

I'm wondering if this code block is just a leftover, because I think the custom css file is loaded here.

@BeyondEvil
Copy link
Contributor

Mind sharing some details about your environment? @wanam

OS
python version
pytest-html version
any other versions you might thing are pertinent?

Also, could you provide a sample css-file that causes the error?

Thanks!

@wanam
Copy link
Contributor Author

wanam commented Oct 21, 2019

OS: Ubuntu 18.04.3 LTS
platform linux -- Python 3.7.2, pytest-5.1.2, py-1.7.0, pluggy-0.13.0
plugins: metadata-1.8.0, csv-2.0.1, html-2.0.0

venv/lib/python3.7/site-packages/pytest_html/plugin.py:71: ResourceWarning: unclosed file <_io.TextIOWrapper name='assets/style.css' mode='r' encoding='UTF-8'>
  open(csspath)
ResourceWarning: Enable tracemalloc to get the object allocation traceback

Concerning the asset, you can reproduce the issue with the default asset: https://github.com/pytest-dev/pytest-html/blob/master/pytest_html/resources/style.css

@janvanoverwalle
Copy link

Have had the same warning appear on Windows.

OS: Windows 10.0.18362 Build 18362
platform win32 -- Python 3.7.3, pytest-5.2.2, py-1.8.0, pluggy-0.13.0
plugins: html-2.0.0, metadata-1.8.0

It does indeed seem, to me, like a redundant or leftover step in the pytest_html\plugin.py file as @wanam mentioned.

@krzysztof-pawlik-gat
Copy link
Contributor

I believe this will be solved when #235 is merged.

@BeyondEvil
Copy link
Contributor

BeyondEvil commented Nov 3, 2019

I'm terribly sorry, I thought I had merged #235 already!

@wanam @janvanoverwalle Do you mind trying the patch (it's on master now) and see if that fixes your issue as well? 🙏

If it does, I'll release a new version instantly!

@wanam
Copy link
Contributor Author

wanam commented Nov 4, 2019

Tested the patch, and it seems fixed, thanks @krzysztof-pawlik-gat !
@BeyondEvil could you also check this one #248 before releasing?

@janvanoverwalle
Copy link

Appears fixed from my end as well. Thanks!

@BeyondEvil
Copy link
Contributor

Awesome! Thank you everyone! 🙏

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

4 participants