1
"""Test for the "import *" functionality.
2

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

7 68
prev_locals = list(locals())
8 68
from dateutil import *
9 68
new_locals = {name:value for name,value in locals().items()
10
              if name not in prev_locals}
11 68
new_locals.pop('prev_locals')
12

13

14 68
@pytest.mark.import_star
15 21
def test_imported_modules():
16
    """ Test that `from dateutil import *` adds modules in __all__ locally """
17 68
    import dateutil.easter
18 68
    import dateutil.parser
19 68
    import dateutil.relativedelta
20 68
    import dateutil.rrule
21 68
    import dateutil.tz
22 68
    import dateutil.utils
23 68
    import dateutil.zoneinfo
24

25 68
    assert dateutil.easter == new_locals.pop("easter")
26 68
    assert dateutil.parser == new_locals.pop("parser")
27 68
    assert dateutil.relativedelta == new_locals.pop("relativedelta")
28 68
    assert dateutil.rrule == new_locals.pop("rrule")
29 68
    assert dateutil.tz == new_locals.pop("tz")
30 68
    assert dateutil.utils == new_locals.pop("utils")
31 68
    assert dateutil.zoneinfo == new_locals.pop("zoneinfo")
32

33 68
    assert not new_locals

Read our documentation on viewing source code .

Loading