diff --git a/.gitignore b/.gitignore index caad7d9..f2c7267 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.pyc *.swp .DS_Store +.tox build diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b7a7531 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,21 @@ +language: python +python: "2.7" +sudo: false + +env: + - TOX_ENV=py27 + - TOX_ENV=py33 + - TOX_ENV=py34 + - TOX_ENV=py35 + +install: + - pip install tox --use-mirrors + +script: + - tox -e $TOX_ENV + +matrix: + # Python 3.5 not yet available on travis, watch this to see when it is. + fast_finish: true + allow_failures: + - env: TOX_ENV=py35 diff --git a/Tests/tests.py b/Tests/tests.py index fa93c10..83b5951 100644 --- a/Tests/tests.py +++ b/Tests/tests.py @@ -27,14 +27,15 @@ class PdfReaderTestCases(unittest.TestCase): ipdf_p1 = ipdf.getPage(0) # Retrieve the text of the PDF - pdftext_file = open(os.path.join(RESOURCE_ROOT, 'crazyones.txt'), 'r') - pdftext = pdftext_file.read() - ipdf_p1_text = ipdf_p1.extractText().replace('\n', '') + with open(os.path.join(RESOURCE_ROOT, 'crazyones.txt'), 'rb') as pdftext_file: + pdftext = pdftext_file.read() + + ipdf_p1_text = ipdf_p1.extractText().replace('\n', '').encode('utf-8') # Compare the text of the PDF to a known source - self.assertEqual(ipdf_p1_text.encode('utf-8', errors='ignore'), pdftext, + self.assertEqual(ipdf_p1_text, pdftext, msg='PDF extracted text differs from expected value.\n\nExpected:\n\n%r\n\nExtracted:\n\n%r\n\n' - % (pdftext, ipdf_p1_text.encode('utf-8', errors='ignore'))) + % (pdftext, ipdf_p1_text)) class AddJsTestCase(unittest.TestCase): diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..02e3dfa --- /dev/null +++ b/tox.ini @@ -0,0 +1,21 @@ +[tox] +envlist = + py26, py27, py33, py34, py35 + +[testenv] +commands = python -m unittest Tests.tests + +[testenv:py26] +basepython = python2.6 + +[testenv:py27] +basepython = python2.7 + +[testenv:py33] +basepython = python3.3 + +[testenv:py34] +basepython = python3.4 + +[testenv:py35] +basepython = python3.5