Test failures with Python 3.2 and enabled warnings

Bug #951257 reported by Arfrever Frehtes Taifersar Arahesis
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-distutils-extra
New
Undecided
Unassigned

Bug Description

12 tests fail with Python 3.2 and enabled warnings. Warnings are disabled by default in Python 2.7 and >=3.2. Warnings can be enabled by -Wd option or PYTHONWARNINGS="d" environmental variable.

'contents = open(path).read()' should be changed to 'file = open(path); contents = file.read(); file.close()' or 'with open(path) as file: contents = file.read()'.

Example failure:
$ PYTHONPATH="." python3.2 -Wd test/auto.py
..F..F....FFF..FFFFF.FF.
======================================================================
FAIL: test_dbus (__main__.T)
D-BUS configuration and service files
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test/auto.py", line 149, in test_dbus
    self.assertEqual(e, '')
AssertionError: "/tmp/python-distutils-extra-2.32/DistUtilsExtra/auto.py:175: ResourceWarning: u [truncated]... != ''
- /tmp/python-distutils-extra-2.32/DistUtilsExtra/auto.py:175: ResourceWarning: unclosed file <_io.TextIOWrapper name='daemon/defaults.conf' mode='r' encoding='UTF-8'>
- if '-//freedesktop//DTD D-BUS Bus Configuration' in open(f).read():
- /tmp/python-distutils-extra-2.32/DistUtilsExtra/auto.py:175: ResourceWarning: unclosed file <_io.TextIOWrapper name='daemon/com.example.foo.conf' mode='r' encoding='UTF-8'>
- if '-//freedesktop//DTD D-BUS Bus Configuration' in open(f).read():
- /tmp/python-distutils-extra-2.32/DistUtilsExtra/auto.py:185: ResourceWarning: unclosed file <_io.TextIOWrapper name='daemon/com.example.foo.service' mode='r' encoding='UTF-8'>
- lines = [l.strip() for l in open(f).readlines()]
- /tmp/python-distutils-extra-2.32/DistUtilsExtra/auto.py:185: ResourceWarning: unclosed file <_io.TextIOWrapper name='gui/com.example.foo.gui.service' mode='r' encoding='UTF-8'>
- lines = [l.strip() for l in open(f).readlines()]
- /tmp/python-distutils-extra-2.32/DistUtilsExtra/auto.py:185: ResourceWarning: unclosed file <_io.TextIOWrapper name='stuff/super.service' mode='r' encoding='UTF-8'>
- lines = [l.strip() for l in open(f).readlines()]

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.