File: test_subprocess.py

package info (click to toggle)
python-astropy 1.3-8~bpo8%2B2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 44,292 kB
  • sloc: ansic: 160,360; python: 137,322; sh: 11,493; lex: 7,638; yacc: 4,956; xml: 1,796; makefile: 474; cpp: 364
file content (21 lines) | stat: -rw-r--r-- 923 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from ...tests.helper import catch_warnings
from ..exceptions import AstropyDeprecationWarning
from ...extern.six.moves import reload_module


def test_import_warning():
    # this import *maybe* raises the warning too, but we force the matter below
    from ..compat import subprocess  # pylint: disable=W0611

    with catch_warnings() as w:
        # this ensures the warning will be re-issues at reload.  Without this,
        # the warning is missing if you invoke astropy.test twice in the same
        # python session
        if hasattr(subprocess, '__warningregistry__'):
            subprocess.__warningregistry__.clear()
        reload_module(subprocess)

    assert len(w) == 1
    assert w[0].category == AstropyDeprecationWarning
    assert w[0].message.args[0] == ("astropy.utils.compat.subprocess is now deprecated "
                                    "- use the Python subprocess module directly instead")