Skip to content

Commit

Permalink
Change the way we skip tests based on missing modules
Browse files Browse the repository at this point in the history
  • Loading branch information
filwaitman committed Jan 11, 2018
1 parent e513215 commit 01cd903
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions djangocms_text_ckeditor/tests/test_plugin.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
import copy
import importlib
import json
import re
import unittest
Expand All @@ -16,6 +15,18 @@
from django.utils.html import escape
from django.utils.http import urlencode, urlunquote

try:
from djangocms_transfer.exporter import export_page
HAS_DJANGOCMS_TRANSFER = True
except ImportError:
HAS_DJANGOCMS_TRANSFER = False

try:
import djangocms_translations # noqa
HAS_DJANGOCMS_TRANSLATIONS = True
except ImportError:
HAS_DJANGOCMS_TRANSLATIONS = False

from djangocms_text_ckeditor.cms_plugins import TextPlugin
from djangocms_text_ckeditor.models import Text
from djangocms_text_ckeditor.utils import (
Expand All @@ -26,15 +37,6 @@
from .base import BaseTestCase


def _dependencies_are_installed(*modules):
for module in modules:
try:
importlib.import_module(module)
except ImportError:
return False
return True


class PluginActionsTestCase(BaseTestCase):

def get_custom_admin_url(self, plugin_class, name):
Expand Down Expand Up @@ -803,8 +805,8 @@ def test_text_plugin_xss(self):
self.assertEqual(self.reload(plugin).body, '<div>divcontent</div><a>acontent</a>')


@unittest.skipIf(
not(_dependencies_are_installed('djangocms_transfer', 'djangocms_translations')),
@unittest.skipUnless(
HAS_DJANGOCMS_TRANSLATIONS and HAS_DJANGOCMS_TRANSFER and X,
'Optional dependencies for tests are not installed.'
)
class DjangoCMSTranslationsIntegrationTestCase(BaseTestCase):
Expand All @@ -814,7 +816,6 @@ def setUp(self):
self.placeholder = self.page.placeholders.get(slot='content')

def _export_page(self):
from djangocms_transfer.exporter import export_page
return json.loads(export_page(self.page, 'en'))

def test_textfield_without_children(self):
Expand Down

0 comments on commit 01cd903

Please sign in to comment.