File python-django-tables2-tests-noxls.patch of Package python-django-tables2

Index: python-django-tables2/tests/test_export.py
===================================================================
--- python-django-tables2.orig/tests/test_export.py
+++ python-django-tables2/tests/test_export.py
@@ -24,6 +24,10 @@ try:
 except ImproperlyConfigured:
     TableExport = None
 
+try:
+    import xlwt
+except ImportError:
+    xlwt = None
 
 NAMES = [("Yildiz", "van der Kuil"), ("Lindi", "Hakvoort"), ("Gerardo", "Castelein")]
 NAMES_LIST_OF_DICTS = [
@@ -253,6 +257,7 @@ class AdvancedExportViewTest(TestCase):
         Occupation.objects.create(name="Timmerman", boolean=True, region=vlaanderen)
         Occupation.objects.create(name="Ecoloog", boolean=False, region=vlaanderen)
 
+    @skipIf(xlwt is None, "tablib[xls] (xlwt) is required to run this export test")
     def test_should_work_with_foreign_keys(self):
         response = OccupationView.as_view()(build_request("/?_export=xls"))
         data = response.content
@@ -261,6 +266,7 @@ class AdvancedExportViewTest(TestCase):
         self.assertTrue(data.find(b"Ecoloog"))
         self.assertTrue(data.find(b"Timmerman"))
 
+    @skipIf(xlwt is None, "tablib[xls] (xlwt) is required to run this export test")
     def test_datetime_xls(self):
         """Verify datatime objects can be exported to xls."""
         utc = pytz.timezone("UTC")
@@ -371,8 +377,9 @@ class UnicodeExportViewTest(TestCase):
         self.assertEqual(response.getvalue().decode("utf8"), expected_csv)
 
         # smoke tests, hard to test this binary format for string containment
-        response = OccupationView.as_view()(build_request("/?_export=xls"))
-        self.assertGreater(len(response.content), len(expected_csv))
+        if xlwt is not None:
+            response = OccupationView.as_view()(build_request("/?_export=xls"))
+            self.assertGreater(len(response.content), len(expected_csv))
 
         response = OccupationView.as_view()(build_request("/?_export=xlsx"))
         self.assertGreater(len(response.content), len(expected_csv))
@@ -387,6 +394,7 @@ class UnicodeExportViewTest(TestCase):
         response = exporter.response()
         self.assertEqual(response.getvalue().decode("utf8"), unicode_header + "\r\n")
 
-        exporter = TableExport("xls", Table([]))
-        # this would fail if the header contains unicode and string converstion is attempted.
-        exporter.export()
+        if xlwt is not None:
+            exporter = TableExport("xls", Table([]))
+            # this would fail if the header contains unicode and string converstion is attempted.
+            exporter.export()
openSUSE Build Service is sponsored by