summaryrefslogtreecommitdiff
path: root/tests/utils.py
blob: beba759bcb020154e096af534a2b6223777947e9 (plain)
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
import shutil

from django.test import TestCase
from django.core.management import call_command
from django.conf import settings


class CollectStaticTestCase(TestCase):
    @classmethod
    def setUpClass(cls):
        super(CollectStaticTestCase, cls).setUpClass()
        call_command('collectstatic', interactive=False, verbosity=0)


class NoCollectStaticTestCase(TestCase):
    @classmethod
    def setUpClass(cls):
        super(NoCollectStaticTestCase, cls).setUpClass()
        shutil.rmtree(settings.STATIC_ROOT, ignore_errors=True)


def clean_css(string):
    # The output of the compiled CSS doesn't have a newline between the ; and
    # the } for some reason.
    return string.strip() \
        .replace('\n', '') \
        .replace('; ', ';')