Repository: matrix-org/sydent (language: python)

Issue:
Replace mock with unittest.mock
Mock is now part of Python's standard library; we should be able to drop it from our setup.py dependencies and use [unittest.mock](https://docs.python.org/3/library/unittest.mock.html) directly.


Discussion / hints:
https://github.com/matrix-org/synapse/pull/9772/commits/df079f15e428ecfc74cae8079f349fdf5604f66f has some handy sed commands for this:

```bash
sed -i "" "s/^from mock import/from unittest.mock import/g" **/*.py
sed -i "" "s/^import mock/from unittest import mock/g" **/*.py
```

It did need a little massaging afterward though.

Fix patch:
diff --git a/changelog.d/370.misc b/changelog.d/370.misc
new file mode 100644
index 00000000..52ce9f36
--- /dev/null
+++ b/changelog.d/370.misc
@@ -0,0 +1,1 @@
+Use `mock` module from the standard library.
diff --git a/setup.py b/setup.py
index 6f671b4d..3eaf3281 100644
--- a/setup.py
+++ b/setup.py
@@ -52,7 +52,6 @@ def read(fname):
         "netaddr>=0.7.0",
         "sortedcontainers>=2.1.0",
         "pyyaml>=3.11",
-        "mock>=3.0.5",
         "flake8==3.9.2",
         "black==21.5b1",
         "isort==5.8.0",


Test patch:
diff --git a/tests/test_replication.py b/tests/test_replication.py
index 2775c1a7..46db25d0 100644
--- a/tests/test_replication.py
+++ b/tests/test_replication.py
@@ -1,6 +1,6 @@
 import json
+from unittest.mock import Mock
 
-from mock import Mock
 from twisted.internet import defer
 from twisted.trial import unittest
 from twisted.web.client import Response