PDF: Use pytest.mark.skipif for skipping tests
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Mon, 15 Apr 2013 21:34:27 +0000 (23:34 +0200)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Tue, 16 Apr 2013 21:39:01 +0000 (23:39 +0200)
Instead of leaving test early if they can not run, use the
pytest.mark.skipif marked to tell the test system not to
even run the test.

This also adds to the stats, because skipped tests are
counted differently. Thus making it obvious, that some
tests did not run, because of any reason.

mediagoblin/tests/test_pdf.py
mediagoblin/tests/test_submission.py

index a3979a25cf328a3804c0b5f44a9aa14c19c67924..b8c21bdb5265dbd39774c73e7684ee16f8e8b2db 100644 (file)
 import tempfile
 import shutil
 import os
-
+import pytest
 
 from mediagoblin.media_types.pdf.processing import (
     pdf_info, check_prerequisites, create_pdf_thumb)
 
 GOOD='mediagoblin/tests/test_submission/good.pdf'
 
+@pytest.mark.skipif("not check_prerequisites()")
 def test_pdf():
-    if not check_prerequisites():
-        return
     good_dict = {'pdf_version_major': 1, 'pdf_title': '',
         'pdf_page_size_width': 612, 'pdf_author': '',
         'pdf_keywords': '', 'pdf_pages': 10,
index 462a16536bf38b10009e3c33afa5abb8c7990aed..7c9b3115d1cfe6306743160e93d9d45a1d190592 100644 (file)
@@ -20,6 +20,7 @@ sys.setdefaultencoding('utf-8')
 
 import urlparse
 import os
+import pytest
 
 from pkg_resources import resource_filename
 
@@ -128,9 +129,8 @@ class TestSubmission:
         self._setup(test_app)
         self.check_normal_upload(u'Normal upload 2', GOOD_PNG)
 
+    @pytest.mark.skipif("not pdf_check_prerequisites()")
     def test_normal_pdf(self, test_app):
-        if not pdf_check_prerequisites():
-            return
         self._setup(test_app)
         response, context = self.do_post({'title': u'Normal upload 3 (pdf)'},
                                          do_follow=True,