thp / urlwatch

Watch (parts of) webpages and get notified when something changes via e-mail, on your phone or via other means. Highly configurable.
https://thp.io/2008/urlwatch/
Other
2.81k stars 352 forks source link

Fix "ResourceWarning: unclosed file" warnings #678

Closed sbraz closed 2 years ago

sbraz commented 2 years ago

This fixes (amongst others):

=================================================== warnings summary ===================================================
lib/urlwatch/tests/test_filter_documentation.py:42                                                                                                                                                                 
  /var/tmp/portage/www-misc/urlwatch-2.24/work/urlwatch-2.24/lib/urlwatch/tests/test_filter_documentation.py:42: ResourceWarning: unclosed file <_io.TextIOWrapper name='/var/tmp/portage/www-misc/urlwatch-2.24/work/urlwatch-2.24/lib/urlwatch/tests/../../../docs/source/filters.rst' mode='r' encoding='UTF-8'>                                                                                                                   
    doc = parse_rst(open(os.path.join(root, 'docs/source/filters.rst')).read())                                                                                                                                    

lib/urlwatch/tests/test_filters.py:39                                                                                                                                                                              
  /var/tmp/portage/www-misc/urlwatch-2.24/work/urlwatch-2.24/lib/urlwatch/tests/test_filters.py:39: ResourceWarning: unclosed file <_io.TextIOWrapper name='/var/tmp/portage/www-misc/urlwatch-2.24/work/urlwatch-2.24/lib/urlwatch/tests/data/filter_tests.yaml' mode='r' encoding='utf8'>                                                                                                                                           
    FILTER_TESTS = yaml.safe_load(open(os.path.join(os.path.dirname(__file__), 'data/filter_tests.yaml'), 'r', encoding='utf8'))

lib/urlwatch/tests/test_filter_documentation.py: 27 warnings                                                                                                                                                       
  /var/tmp/portage/www-misc/urlwatch-2.24/work/urlwatch-2.24/lib/urlwatch/tests/test_filter_documentation.py:59: ResourceWarning: unclosed file <_io.TextIOWrapper name='/var/tmp/portage/www-misc/urlwatch-2.24/work/urlwatch-2.24/lib/urlwatch/tests/data/filter_documentation_testdata.yaml' mode='r' encoding='UTF-8'>                                                                                                            
    testdata = yaml.safe_load(open(os.path.join(here, 'data/filter_documentation_testdata.yaml')).read())