Skip to content

Commit bccf1dd

Browse files
committed
Patch redis module in tests
Make sure the tests can be run even if redis isn't installed.
1 parent 0427f63 commit bccf1dd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/test_token_plugins.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
""" Unit tests for Token plugins"""
44

5+
import sys
56
import unittest
67
from unittest.mock import patch, mock_open, MagicMock
78
from jwcrypto import jwt, jwk
@@ -178,6 +179,14 @@ def test_asymmetric_jwe_token_plugin(self):
178179
self.assertEqual(result[1], "remote_port")
179180

180181
class TokenRedisTestCase(unittest.TestCase):
182+
def setUp(self):
183+
try:
184+
import redis
185+
except ImportError:
186+
patcher = patch.dict(sys.modules, {'redis': MagicMock()})
187+
patcher.start()
188+
self.addCleanup(patcher.stop)
189+
181190
@patch('redis.Redis')
182191
def test_empty(self, mock_redis):
183192
plugin = TokenRedis('127.0.0.1:1234')

0 commit comments

Comments
 (0)