forked from django-nonrel/mongodb-engine
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.py
35 lines (24 loc) · 972 Bytes
/
utils.py
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
from django.conf import settings
from django.db import connections
from django.db.models import Model
from django.test import TestCase
from django.utils.unittest import skip
class TestCase(TestCase):
def setUp(self):
super(TestCase, self).setUp()
if getattr(settings, 'TEST_DEBUG', False):
settings.DEBUG = True
def assertEqualLists(self, a, b):
self.assertEqual(list(a), list(b))
def skip_all_except(*tests):
class meta(type):
def __new__(cls, name, bases, dict):
for attr in dict.keys():
if attr.startswith('test_') and attr not in tests:
del dict[attr]
return type.__new__(cls, name, bases, dict)
return meta
def get_collection(model_or_name):
if isinstance(model_or_name, type) and issubclass(model_or_name, Model):
model_or_name = model_or_name._meta.db_table
return connections['default'].get_collection(model_or_name)