geopython / pywps

PyWPS is an implementation of the Web Processing Service standard from the Open Geospatial Consortium. PyWPS is written in Python.
https://pywps.org
MIT License
177 stars 117 forks source link

fix safe file handling in unit tests #109

Closed tomkralidis closed 8 years ago

tomkralidis commented 8 years ago

Description

Unit tests in a Python 3 environment yield ResourceWarning warnings like:

/home/travis/build/geopython/pywps/tests/test_inout.py:64: ResourceWarning: unclosed file <_io.FileIO name='/tmp/tmpwbpvbq0c' mode='rb'>

Environment

# in a Python 3 virtualenv
python -m unittest tests

Additional Information

Initial discussion in #106.

Example can be found in current travis builds: https://travis-ci.org/geopython/pywps/jobs/111190874#L360

mishravikas commented 8 years ago

Can I take this bug?

tomkralidis commented 8 years ago

Sounds good @mishravikas!

jachym commented 8 years ago

@mishravikas go for it, but I'm not sure it's easy to be fixed. Have a look in it and in case, you are not sure how to approach, just move on with your tasks

ldesousa commented 8 years ago

Line 160 in inout/basic.py, in the method get_stream() save a reference to the file object. CLose this file object after the handler is called - Process class, _run_process() method.

jachym commented 8 years ago

https://docs.python.org/3/reference/datamodel.html del object destroyer should do it

jachym commented 8 years ago

175 fixes this