1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
From: Michael Fladischer <FladischerMichael@fladi.at>
Date: Sun, 26 May 2019 19:21:16 +0200
Subject: Skip tests if required modules are not installed.
---
tests/test_azure.py | 6 ++++++
tests/test_dropbox.py | 6 ++++++
tests/test_gcloud.py | 7 +++++++
tests/test_s3.py | 7 +++++++
tests/test_sftp.py | 7 ++++++-
5 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/tests/test_azure.py b/tests/test_azure.py
index 059cb2e..39ec935 100644
--- a/tests/test_azure.py
+++ b/tests/test_azure.py
@@ -1,3 +1,9 @@
+import unittest
+try:
+ import azure
+except ImportError:
+ raise unittest.SkipTest("azure package not installed, skipping tests")
+
import datetime
from datetime import timedelta
from unittest import mock
diff --git a/tests/test_dropbox.py b/tests/test_dropbox.py
index 6736b47..dce1bf1 100644
--- a/tests/test_dropbox.py
+++ b/tests/test_dropbox.py
@@ -1,3 +1,9 @@
+import unittest
+try:
+ import dropbox
+except ImportError:
+ raise unittest.SkipTest("dropbox package not installed, skipping tests")
+
import io
from datetime import datetime
from unittest import mock
diff --git a/tests/test_gcloud.py b/tests/test_gcloud.py
index aa4ba48..e545ba8 100644
--- a/tests/test_gcloud.py
+++ b/tests/test_gcloud.py
@@ -4,6 +4,13 @@ import mimetypes
from datetime import timedelta
from unittest import mock
+try:
+ import google.cloud
+except ImportError:
+ import unittest
+ raise unittest.SkipTest("google.cloud package not installed, skipping tests")
+
+
from django.core.exceptions import ImproperlyConfigured
from django.core.files.base import ContentFile
from django.test import TestCase
diff --git a/tests/test_s3.py b/tests/test_s3.py
index c131b89..71b703c 100644
--- a/tests/test_s3.py
+++ b/tests/test_s3.py
@@ -9,6 +9,13 @@ from unittest import mock
from unittest import skipIf
from urllib.parse import urlparse
+try:
+ import moto
+except ImportError:
+ import unittest
+ raise unittest.SkipTest("moto package not installed, skipping tests")
+
+
import boto3
import boto3.s3.transfer
import botocore
diff --git a/tests/test_sftp.py b/tests/test_sftp.py
index ec543c6..3f50a30 100644
--- a/tests/test_sftp.py
+++ b/tests/test_sftp.py
@@ -1,3 +1,9 @@
+import unittest
+try:
+ import paramiko
+except ImportError:
+ raise unittest.SkipTest("paramiko package not installed, skipping tests")
+
import io
import os
import socket
@@ -5,7 +11,6 @@ import stat
from unittest.mock import MagicMock
from unittest.mock import patch
-import paramiko
from django.core.files.base import File
from django.test import TestCase
from django.test import override_settings
|