aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/python-dateutil/py2/tests/test_import_star.py
blob: 2fb70981286886ac6156c51c00707198977b5d00 (plain) (blame)
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
"""Test for the "import *" functionality.

As import * can be only done at module level, it has been added in a separate file
"""
import pytest

prev_locals = list(locals())
from dateutil import *
new_locals = {name:value for name,value in locals().items()
              if name not in prev_locals}
new_locals.pop('prev_locals')


@pytest.mark.import_star
def test_imported_modules():
    """ Test that `from dateutil import *` adds modules in __all__ locally """
    import dateutil.easter
    import dateutil.parser
    import dateutil.relativedelta
    import dateutil.rrule
    import dateutil.tz
    import dateutil.utils
    import dateutil.zoneinfo

    assert dateutil.easter == new_locals.pop("easter")
    assert dateutil.parser == new_locals.pop("parser")
    assert dateutil.relativedelta == new_locals.pop("relativedelta")
    assert dateutil.rrule == new_locals.pop("rrule")
    assert dateutil.tz == new_locals.pop("tz")
    assert dateutil.utils == new_locals.pop("utils")
    assert dateutil.zoneinfo == new_locals.pop("zoneinfo")

    assert not new_locals