bpo-38155: Add __all__ to datetime module (GH-16203)
https://bugs.python.org/issue38155
This commit is contained in:
parent
9fdc64cf12
commit
96b1c59c71
|
@ -4,6 +4,10 @@ See http://www.iana.org/time-zones/repository/tz-link.html for
|
||||||
time zone and DST data sources.
|
time zone and DST data sources.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
__all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo",
|
||||||
|
"MINYEAR", "MAXYEAR")
|
||||||
|
|
||||||
|
|
||||||
import time as _time
|
import time as _time
|
||||||
import math as _math
|
import math as _math
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -62,6 +62,12 @@ class TestModule(unittest.TestCase):
|
||||||
self.assertEqual(datetime.MINYEAR, 1)
|
self.assertEqual(datetime.MINYEAR, 1)
|
||||||
self.assertEqual(datetime.MAXYEAR, 9999)
|
self.assertEqual(datetime.MAXYEAR, 9999)
|
||||||
|
|
||||||
|
def test_all(self):
|
||||||
|
"""Test that __all__ only points to valid attributes."""
|
||||||
|
all_attrs = dir(datetime_module)
|
||||||
|
for attr in datetime_module.__all__:
|
||||||
|
self.assertIn(attr, all_attrs)
|
||||||
|
|
||||||
def test_name_cleanup(self):
|
def test_name_cleanup(self):
|
||||||
if '_Pure' in self.__class__.__name__:
|
if '_Pure' in self.__class__.__name__:
|
||||||
self.skipTest('Only run for Fast C implementation')
|
self.skipTest('Only run for Fast C implementation')
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Add ``__all__`` to :mod:`datetime`. Patch by Tahia Khan.
|
Loading…
Reference in New Issue