dateutil / dateutil
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 17
import pytest
6

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

13

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

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

33 17
    assert not new_locals

Read our documentation on viewing source code .

Loading