Skip to content

Commit

Permalink
Only check if MongoDB is running once durring tests
Browse files Browse the repository at this point in the history
This should increase the speed of the unit test process because
it changes the check for if MongoDB is running from every time
a test case is run, to only once per test case.
  • Loading branch information
gunthercox committed May 4, 2017
1 parent 1011b00 commit f430f04
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tests/base_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ def tearDown(self):

class ChatBotMongoTestCase(ChatBotTestCase):

def setUp(self):
@classmethod
def setUpClass(cls):
from pymongo.errors import ServerSelectionTimeoutError
from pymongo import MongoClient

# Skip these tests if a mongo client is not running
# Check if the mongo client is running
try:
client = MongoClient(
serverSelectionTimeoutMS=0.1
Expand All @@ -56,8 +57,6 @@ def setUp(self):
except ServerSelectionTimeoutError:
raise SkipTest('Unable to connect to Mongo DB.')

super(ChatBotMongoTestCase, self).setUp()

def get_kwargs(self):
kwargs = super(ChatBotMongoTestCase, self).get_kwargs()
kwargs['database'] = self.random_string()
Expand Down

0 comments on commit f430f04

Please sign in to comment.