File: test_utils.py

package info (click to toggle)
python-astropy-helpers 1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 756 kB
  • ctags: 698
  • sloc: python: 5,929; ansic: 88; makefile: 11
file content (34 lines) | stat: -rw-r--r-- 996 bytes parent folder | download | duplicates (17)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# namedtuple is needed for find_mod_objs so it can have a non-local module

import sys
from collections import namedtuple

import pytest

from ..utils import find_mod_objs

PY3 = sys.version_info[0] >= 3
pytestmark = pytest.mark.skipif("PY3")


def test_find_mod_objs():
    lnms, fqns, objs = find_mod_objs('astropy_helpers')

    # this import  is after the above call intentionally to make sure
    # find_mod_objs properly imports astropy on its own
    import astropy_helpers

    # just check for astropy.test ... other things might be added, so we
    # shouldn't check that it's the only thing
    assert lnms == []

    lnms, fqns, objs = find_mod_objs(
        'astropy_helpers.sphinx.ext.tests.test_utils', onlylocals=False)

    assert namedtuple in objs

    lnms, fqns, objs = find_mod_objs(
        'astropy_helpers.sphinx.ext.tests.test_utils', onlylocals=True)
    assert 'namedtuple' not in lnms
    assert 'collections.namedtuple' not in fqns
    assert namedtuple not in objs