Skip to content

Commit b610f0b

Browse files
committed
Added a skipIf() decorator for a test which should not be run unless the ghostscript binary is available in the test environment.
- Legacy-Id: 16076
1 parent 7224e06 commit b610f0b

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

ietf/meeting/tests_views.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import datetime
88
import urlparse
99
import random
10+
from unittest import skipIf
1011

1112
import debug # pyflakes:ignore
1213

@@ -41,6 +42,16 @@
4142
from ietf.submit.tests import submission_file
4243

4344

45+
if os.path.exists(settings.GHOSTSCRIPT_COMMAND):
46+
skip_pdf_tests = False
47+
skip_message = ""
48+
else:
49+
import sys
50+
skip_pdf_tests = True
51+
skip_message = ("Skipping pdf test: The binary for ghostscript wasn't found in the\n "
52+
"location indicated in settings.py.")
53+
sys.stderr.write(" "+skip_message+'\n')
54+
4455
class MeetingTests(TestCase):
4556
def setUp(self):
4657
self.materials_dir = self.tempdir('materials')
@@ -501,6 +512,7 @@ def test_session_draft_tarfile(self):
501512
self.assertEqual(response.get('Content-Type'), 'application/octet-stream')
502513
os.unlink(filename)
503514

515+
@skipIf(skip_pdf_tests, skip_message)
504516
def test_session_draft_pdf(self):
505517
session = SessionFactory(group__type_id='wg',meeting__type_id='ietf')
506518
doc = DocumentFactory(type_id='draft')

ietf/meeting/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,8 @@ def session_draft_pdf(request, num, acronym):
723723
pdfmarks.close()
724724
pdfh, pdfn = mkstemp()
725725
os.close(pdfh)
726-
code, out, err = pipe("gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=" + pdfn + " " + pdf_list + " " + pmn)
726+
gs = settings.GHOSTSCRIPT_COMMAND
727+
code, out, err = pipe(gs + " -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=" + pdfn + " " + pdf_list + " " + pmn)
727728
assertion('code == 0')
728729

729730
pdf = open(pdfn,"r")

ietf/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,9 @@ def skip_unreadable_post(record):
805805
HTPASSWD_COMMAND = "/usr/bin/htpasswd"
806806
HTPASSWD_FILE = "/www/htpasswd"
807807

808+
# Generation of pdf files
809+
GHOSTSCRIPT_COMMAND = "/usr/bin/gs"
810+
808811
# Generation of bibxml files for xml2rfc
809812
BIBXML_BASE_PATH = '/a/www/ietf-ftp/xml2rfc'
810813

0 commit comments

Comments
 (0)