Skip to content

Commit

Permalink
unittest missing lxml package
Browse files Browse the repository at this point in the history
  • Loading branch information
jbremer committed Mar 10, 2017
1 parent e0d255e commit 77d3081
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ before_install:

install:
- python setup.py develop
- pip install pytest pytest-cov coveralls
- pip install pytest pytest-cov mock coveralls

script:
- py.test --cov=peepdf
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ install:
- "set PATH=%PYTHON%;%PYTHON%/Scripts;%PATH%"

- "python.exe setup.py develop"
- "pip.exe install pytest pytest-cov"
- "pip.exe install pytest pytest-cov mock"

build: false

Expand Down
4 changes: 3 additions & 1 deletion peepdf/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@
try:
from lxml import etree
except:
pass
etree = None


def getPeepXML(statsDict, version, revision):
assert etree is not None, "lxml must be installed for --xml"

root = etree.Element('peepdf_analysis', version=version + ' r' + revision, url='http://peepdf.eternal-todo.com',
author='Jose Miguel Esparza')
analysisDate = etree.SubElement(root, 'date')
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
"colorama==0.3.7",
"Pillow==3.2.0",
"pythonaes==1.0",
"lxml==3.6.0",
],
entry_points={
"console_scripts": [
"peepdf = peepdf.main:main",
],
},
packages=["peepdf"],
packages=[
"peepdf",
],
)
9 changes: 9 additions & 0 deletions tests/test_pee.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
# along with peepdf. If not, see <http://www.gnu.org/licenses/>.
#

import mock
import peepdf
import peepdf.main
import pytest

def test_whitespace_after_opening():
p = peepdf.PDFCore.PDFParser()
Expand All @@ -35,3 +38,9 @@ def test_whitespace_after_opening():
assert obj.object.errors != [
"Decoding error: Error decompressing string"
]

def test_lxml_missing():
with mock.patch.dict(peepdf.main.__dict__, {"etree": None}):
with pytest.raises(AssertionError) as e:
peepdf.main.getPeepXML(None, None, None)
e.match("lxml must be installed")

0 comments on commit 77d3081

Please sign in to comment.