/usr/lib/python2.7/dist-packages/openpyxl/xml/tests/test_functions.py is in python-openpyxl 2.4.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | import pytest
try:
from xml.etree.cElementTree import ParseError
except ImportError:
# py26
ParseError = SyntaxError
def test_safe_iterator_none():
from .. functions import safe_iterator
seq = safe_iterator(None)
assert seq == []
import xml
@pytest.mark.parametrize("xml, tag",
[
("<root xmlns='http://openpyxl.org/ns' />", "root"),
("<root />", "root"),
]
)
def test_localtag(xml, tag):
from .. functions import localname
from .. functions import fromstring
node = fromstring(xml)
assert localname(node) == tag
@pytest.mark.lxml_required
def test_dont_resolve():
from ..functions import fromstring
s = b"""<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE foo [
<!ELEMENT foo ANY >
<!ENTITY xxe SYSTEM "file:///dev/random" >]>
<foo>&xxe;</foo>"""
node = fromstring(s)
@pytest.mark.no_lxml
def test_dont_resolve():
from ..functions import fromstring
s = b"""<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE foo [
<!ELEMENT foo ANY >
<!ENTITY xxe SYSTEM "file:///dev/random" >]>
<foo>&xxe;</foo>"""
with pytest.raises(ParseError):
node = fromstring(s)
|