[damned-lies/testerror] Skip test if translate-toolkit subtitles support is missing



commit 103df6cc4a3cacb369fdd9f9af0f391f60c39eae
Author: Claude Paroz <claude 2xlibre net>
Date:   Mon Jun 25 09:08:03 2018 +0200

    Skip test if translate-toolkit subtitles support is missing

 stats/tests/tests.py | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index 9b28c011..49cb2c38 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -4,6 +4,7 @@ import shutil
 import tempfile
 from datetime import date
 from pathlib import Path
+from unittest import skipUnless
 
 from django.conf import settings
 from django.contrib.auth.models import User
@@ -23,6 +24,13 @@ from languages.models import Language
 
 from .utils import patch_shell_command, test_scratchdir
 
+try:
+    from translate.storage import subtitles
+    has_translate_subtitle_support = True
+except ImportError:
+    has_translate_subtitle_support = False
+
+
 def mocked_checkout(branch):
     """ Replace real vcs checkout by a mocked method """
     if branch.name == 'trunk2':
@@ -503,6 +511,7 @@ class DomainTests(TestCase):
         self.addCleanup(os.remove, str(potfile))
         self.assertTrue(potfile.exists())
 
+    @skipUnless(has_translate_subtitle_support, "This test needs translate-toolit subtitles support.")
     def test_subtitles_pot(self):
         dom = Domain.objects.create(
             module=self.mod, name='po', dtype='ui', directory='subtitles',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]