astropy/astropy — pull request #3096 by sargas (2014-11-12 00:47:11+00:00)
Title: Fix --open-files test with Python 3.3 and newer

Currently, the pytest plugin for open files uses a function that has been depreciated since [this commit](https://hg.python.org/cpython/rev/b81ddaf0db47) in Python 3.3.

Specifically, running `python setup.py test --open-files` gives: (shortening the long lines)
```
astropy/tests/pytest_plugins.py:431:
_

def _get_open_file_list():
fsencoding = sys.getfilesystemencoding()

sproc = subprocess.Popen(
['lsof -F0 -n -p {0}'.format(os.getpid())],
shell=True, stdout=subprocess.PIPE)
output = sproc.communicate()[0].strip()
files = []
for line in output.split(b'\n'):
columns = line.split(b'\0')
mapping = {}
for column in columns:
if len(column) >= 2:
mapping[column[0:1]] = column[1:]

if (mapping.get(b'f') and
mapping.get(b'a', b' ') != b' ' and
mapping.get(b't') == b'REG'):
# Ignore extension modules -- they may be imported by a
# test but are never again closed by the runtime. That's
# ok.
> for suffix, mode, filetype in imp.get_suffixes():
if mapping[b'n'].decode(fsencoding).endswith(suffix):

astropy/tests/pytest_plugins.py:418:
_

def get_suffixes():
warnings.warn('imp.get_suffixes() is deprecated; use the constants '
'defined on importlib.machinery instead',
> DeprecationWarning, 2)
E DeprecationWarning: imp.get_suffixes() is deprecated; use the constants defined on importlib.machinery instead

/usr/lib64/python3.3/imp.py:58: DeprecationWarning
= 96 skipped, 11 xfailed, 5561 error in 200.14 seconds =
```
While `python2.7 setup.py test --open-files` only results in:
```
= 1 failed, 8090 passed, 149 skipped, 43 xfailed, 3 xpassed in 478.00 seconds =
```
(the one failure looks like a numerical issue in `TestFittable1DModels.test_deriv_1D`)

After this PR, the numbers for python 3 go down to:
```
= 1 failed, 5482 passed, 140 skipped, 42 xfailed, 3 xpassed in 292.71 seconds =
```
and is unchanged for python2.

To prevent this from happening again, I also enabled Travis to check for opened files with the newest python2 and python3 versions.