File: test_utils.py

package info (click to toggle)
sphinx-automodapi 0.18.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 944 kB
  • sloc: python: 1,696; makefile: 197
file content (45 lines) | stat: -rw-r--r-- 1,401 bytes parent folder | download | duplicates (3)
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
35
36
37
38
39
40
41
42
43
44
45
# namedtuple is needed for find_mod_objs so it can have a non-local module

from collections import namedtuple

from ..utils import find_mod_objs


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

    # 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(
        'sphinx_automodapi.tests.test_utils', onlylocals=False)

    assert namedtuple in objs

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


def test_find_mod_objs_with_list_of_modules():
    lnms, fqns, objs = find_mod_objs(
        'sphinx_automodapi.tests.test_utils', onlylocals=['sphinx_automodapi'])

    assert namedtuple not in objs
    assert find_mod_objs in objs

    lnms, fqns, objs = find_mod_objs(
        'sphinx_automodapi.tests.test_utils', onlylocals=['collections'])

    assert namedtuple in objs
    assert find_mod_objs not in objs

    lnms, fqns, objs = find_mod_objs(
        'sphinx_automodapi.tests.test_utils', onlylocals=['collections',
                                                          'sphinx_automodapi'])

    assert namedtuple in objs
    assert find_mod_objs in objs