Closes Issue 21222.

Passing name keyword argument to mock.create_autospec now works.
diff --git a/NEWS b/NEWS
index b64189f..6ec5a00 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+- Issue #21222: Passing name keyword argument to mock.create_autospec now
+  works.
+
 - Issue #17826: setting an iterable side_effect on a mock function created by
   create_autospec now works. Patch by Kushal Das.
 
diff --git a/mock.py b/mock.py
index d7c0024..6b325a2 100644
--- a/mock.py
+++ b/mock.py
@@ -2254,6 +2254,8 @@
     elif is_type and instance and not _instance_callable(spec):
         Klass = NonCallableMagicMock
 
+    _name = _kwargs.pop('name', _name)
+
     _new_name = _name
     if _parent is None:
         # for a top level object no _new_name should be set
diff --git a/tests/testmock.py b/tests/testmock.py
index fd184db..5ab845e 100644
--- a/tests/testmock.py
+++ b/tests/testmock.py
@@ -1246,6 +1246,10 @@
                 func.mock_calls, [call(1, 2), call(3, 4)]
             )
 
+    #Issue21222
+    def test_create_autospec_with_name(self):
+        m = mock.create_autospec(object(), name='sweet_func')
+        self.assertIn('sweet_func', repr(m))
 
     def test_mock_add_spec(self):
         class _One(object):