diff options
author | SanthoshBala18 <santhoshbala18@gmail.com> | 2020-01-28 13:20:56 +0530 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2020-01-27 23:50:56 -0800 |
commit | d67de1bfaaa8b9e01c367c34bf76ff86124bf8dc (patch) | |
tree | 30eb847d4541b4b961de624056e68b34553768f1 /numpy | |
parent | 79eff02e7e2c3b1865ee47fa66ae40f44894cadb (diff) | |
download | numpy-d67de1bfaaa8b9e01c367c34bf76ff86124bf8dc.tar.gz |
MAINT: dir(numpy) returned duplicate "testing" (gh-15425)
Modified __dir__() to remove duplicate "Tester/Testing" attribute. Also added a test to verify this.
Closes gh-15383
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/__init__.py | 2 | ||||
-rw-r--r-- | numpy/tests/test_public_api.py | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/numpy/__init__.py b/numpy/__init__.py index 00c4a3d78..c5c58b020 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -215,7 +215,7 @@ else: "{!r}".format(__name__, attr)) def __dir__(): - return list(globals().keys()) + ['Tester', 'testing'] + return list(globals().keys() | {'Tester', 'testing'}) else: # We don't actually use this ourselves anymore, but I'm not 100% sure that diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py index b4aa7ec3d..27ff87f49 100644 --- a/numpy/tests/test_public_api.py +++ b/numpy/tests/test_public_api.py @@ -94,6 +94,12 @@ def test_import_lazy_import(name): assert name in dir(np) +def test_dir_testing(): + """Assert that output of dir has only one "testing/tester" + attribute without duplicate""" + assert len(dir(np)) == len(set(dir(np))) + + def test_numpy_linalg(): bad_results = check_dir(np.linalg) assert bad_results == {} |