aboutsummaryrefslogtreecommitdiffstats
path: root/tests/conftest.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2020-12-21 11:59:35 -0800
committerJesús <heckyel@hyperbola.info>2020-12-21 18:23:09 -0500
commitb11120d000970304b01287a28d6494e4844cfced (patch)
treedf8076e1b2dbe8187f4317cd54a9c92e939d6626 /tests/conftest.py
parent574cb2dae8534a8abba5710217e4f6c8655ff854 (diff)
downloadyt-local-b11120d000970304b01287a28d6494e4844cfced.tar.lz
yt-local-b11120d000970304b01287a28d6494e4844cfced.tar.xz
yt-local-b11120d000970304b01287a28d6494e4844cfced.zip
Exit node retrying: Retry 3 times. Also add tests for it.
Closes #20 Signed-off-by: Jesús <heckyel@hyperbola.info>
Diffstat (limited to 'tests/conftest.py')
-rw-r--r--tests/conftest.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
new file mode 100644
index 0000000..2694317
--- /dev/null
+++ b/tests/conftest.py
@@ -0,0 +1,14 @@
+import pytest
+import urllib3
+import urllib
+import urllib.request
+import socket
+
+# https://realpython.com/pytest-python-testing/
+@pytest.fixture(autouse=True)
+def disable_network_calls(monkeypatch):
+ def stunted_get(*args, **kwargs):
+ raise RuntimeError('Network access not allowed during testing!')
+ monkeypatch.setattr(urllib.request, 'Request', stunted_get)
+ monkeypatch.setattr(urllib3.PoolManager, 'request', stunted_get)
+ monkeypatch.setattr(socket, 'socket', stunted_get)