[3.10] bpo-44353: Expand NewType tests for complex __qualname__ (GH-27311) (GH-27326)

Make NewType pickleable by name.
(cherry picked from commit e89ef0ad2a299770a88ece8f7a316f7d3eb65c9f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
diff --git a/Lib/typing.py b/Lib/typing.py
index 1606de9..ffd35e5 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -2375,8 +2375,10 @@ def name_by_id(user_id: UserId) -> str:
     """
 
     def __init__(self, name, tp):
-        self.__name__ = name
         self.__qualname__ = name
+        if '.' in name:
+            name = name.rpartition('.')[-1]
+        self.__name__ = name
         self.__module__ = _callee(default='typing')
         self.__supertype__ = tp
 
@@ -2386,6 +2388,9 @@ def __repr__(self):
     def __call__(self, x):
         return x
 
+    def __reduce__(self):
+        return self.__qualname__
+
     def __or__(self, other):
         return Union[self, other]