test_import_star.py 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. """Test for the "import *" functionality.
  2. As import * can be only done at module level, it has been added in a separate file
  3. """
  4. import pytest
  5. prev_locals = list(locals())
  6. from dateutil import *
  7. new_locals = {name:value for name,value in locals().items()
  8. if name not in prev_locals}
  9. new_locals.pop('prev_locals')
  10. @pytest.mark.import_star
  11. def test_imported_modules():
  12. """ Test that `from dateutil import *` adds modules in __all__ locally """
  13. import dateutil.easter
  14. import dateutil.parser
  15. import dateutil.relativedelta
  16. import dateutil.rrule
  17. import dateutil.tz
  18. import dateutil.utils
  19. import dateutil.zoneinfo
  20. assert dateutil.easter == new_locals.pop("easter")
  21. assert dateutil.parser == new_locals.pop("parser")
  22. assert dateutil.relativedelta == new_locals.pop("relativedelta")
  23. assert dateutil.rrule == new_locals.pop("rrule")
  24. assert dateutil.tz == new_locals.pop("tz")
  25. assert dateutil.utils == new_locals.pop("utils")
  26. assert dateutil.zoneinfo == new_locals.pop("zoneinfo")
  27. assert not new_locals