[Python-checkins] bpo-41477: Make ctypes optional in test_genericalias (GH-21766)

Victor Stinner webhook-mailer at python.org
Fri Aug 7 11:57:02 EDT 2020


https://github.com/python/cpython/commit/f44693eaed3b9d91a6e415d48224fd4750b59366
commit: f44693eaed3b9d91a6e415d48224fd4750b59366
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-08-07T17:56:42+02:00
summary:

bpo-41477: Make ctypes optional in test_genericalias (GH-21766)

files:
A Misc/NEWS.d/next/Tests/2020-08-07-17-28-49.bpo-41477.GrFexU.rst
M Lib/test/test_genericalias.py

diff --git a/Lib/test/test_genericalias.py b/Lib/test/test_genericalias.py
index 4f3798e8f87d8..1f24469471428 100644
--- a/Lib/test/test_genericalias.py
+++ b/Lib/test/test_genericalias.py
@@ -13,7 +13,10 @@
 from dataclasses import Field
 from functools import partial, partialmethod, cached_property
 from mailbox import Mailbox, _PartialFile
-from ctypes import Array, LibraryLoader
+try:
+    import ctypes
+except ImportError:
+    ctypes = None
 from difflib import SequenceMatcher
 from filecmp import dircmp
 from fileinput import FileInput
@@ -46,43 +49,44 @@ class BaseTest(unittest.TestCase):
     """Test basics."""
 
     def test_subscriptable(self):
-        for t in (type, tuple, list, dict, set, frozenset, enumerate,
-                  defaultdict, deque,
-                  SequenceMatcher,
-                  dircmp,
-                  FileInput,
-                  OrderedDict, Counter, UserDict, UserList,
-                  Pattern, Match,
-                  partial, partialmethod, cached_property,
-                  AbstractContextManager, AbstractAsyncContextManager,
-                  Awaitable, Coroutine,
-                  AsyncIterable, AsyncIterator,
-                  AsyncGenerator, Generator,
-                  Iterable, Iterator,
-                  Reversible,
-                  Container, Collection,
-                  Callable,
-                  Mailbox, _PartialFile,
-                  ContextVar, Token,
-                  Field,
-                  Set, MutableSet,
-                  Mapping, MutableMapping, MappingView,
-                  KeysView, ItemsView, ValuesView,
-                  Sequence, MutableSequence,
-                  MappingProxyType, AsyncGeneratorType,
-                  DirEntry,
-                  chain,
-                  TemporaryDirectory, SpooledTemporaryFile,
-                  Queue, SimpleQueue,
-                  _AssertRaisesContext,
-                  Array, LibraryLoader,
-                  SplitResult, ParseResult,
-                  ValueProxy, ApplyResult,
-                  WeakSet, ReferenceType, ref,
-                  ShareableList, SimpleQueue,
-                  Future, _WorkItem,
-                  Morsel,
-                  ):
+        types = [type, tuple, list, dict, set, frozenset, enumerate,
+                 defaultdict, deque,
+                 SequenceMatcher,
+                 dircmp,
+                 FileInput,
+                 OrderedDict, Counter, UserDict, UserList,
+                 Pattern, Match,
+                 partial, partialmethod, cached_property,
+                 AbstractContextManager, AbstractAsyncContextManager,
+                 Awaitable, Coroutine,
+                 AsyncIterable, AsyncIterator,
+                 AsyncGenerator, Generator,
+                 Iterable, Iterator,
+                 Reversible,
+                 Container, Collection,
+                 Callable,
+                 Mailbox, _PartialFile,
+                 ContextVar, Token,
+                 Field,
+                 Set, MutableSet,
+                 Mapping, MutableMapping, MappingView,
+                 KeysView, ItemsView, ValuesView,
+                 Sequence, MutableSequence,
+                 MappingProxyType, AsyncGeneratorType,
+                 DirEntry,
+                 chain,
+                 TemporaryDirectory, SpooledTemporaryFile,
+                 Queue, SimpleQueue,
+                 _AssertRaisesContext,
+                 SplitResult, ParseResult,
+                 ValueProxy, ApplyResult,
+                 WeakSet, ReferenceType, ref,
+                 ShareableList, SimpleQueue,
+                 Future, _WorkItem,
+                 Morsel]
+        if ctypes is not None:
+            types.extend((ctypes.Array, ctypes.LibraryLoader))
+        for t in types:
             if t is None:
                 continue
             tname = t.__name__
diff --git a/Misc/NEWS.d/next/Tests/2020-08-07-17-28-49.bpo-41477.GrFexU.rst b/Misc/NEWS.d/next/Tests/2020-08-07-17-28-49.bpo-41477.GrFexU.rst
new file mode 100644
index 0000000000000..bf0f54abecd85
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2020-08-07-17-28-49.bpo-41477.GrFexU.rst
@@ -0,0 +1 @@
+Make ctypes optional in test_genericalias.



More information about the Python-checkins mailing list