Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 96b1c59

Browse files
ta1hiapganssle
authored andcommitted
bpo-38155: Add __all__ to datetime module (GH-16203)
https://bugs.python.org/issue38155
1 parent 9fdc64c commit 96b1c59

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

Lib/datetime.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
time zone and DST data sources.
55
"""
66

7+
__all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo",
8+
"MINYEAR", "MAXYEAR")
9+
10+
711
import time as _time
812
import math as _math
913
import sys

Lib/test/datetimetester.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ def test_constants(self):
6262
self.assertEqual(datetime.MINYEAR, 1)
6363
self.assertEqual(datetime.MAXYEAR, 9999)
6464

65+
def test_all(self):
66+
"""Test that __all__ only points to valid attributes."""
67+
all_attrs = dir(datetime_module)
68+
for attr in datetime_module.__all__:
69+
self.assertIn(attr, all_attrs)
70+
6571
def test_name_cleanup(self):
6672
if '_Pure' in self.__class__.__name__:
6773
self.skipTest('Only run for Fast C implementation')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add ``__all__`` to :mod:`datetime`. Patch by Tahia Khan.

0 commit comments

Comments
 (0)