/usr/lib/python2.7/dist-packages/openpyxl/compat/tests/test_compat.py is in python-openpyxl 2.3.0-3.
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | from __future__ import absolute_import
# Copyright (c) 2010-2015 openpyxl
import pytest
@pytest.mark.parametrize("value, result",
[
('s', 's'),
(2.0/3, '0.6666666666666666'),
(1, '1'),
(None, 'none')
]
)
def test_safe_string(value, result):
from openpyxl.compat import safe_string
assert safe_string(value) == result
v = safe_string('s')
assert v == 's'
@pytest.fixture
def dictionary():
return {'1':1, 'a':'b', 3:'d'}
def test_iterkeys(dictionary):
from openpyxl.compat import iterkeys
d = dictionary
assert set(iterkeys(d)) == set(['1', 'a', 3])
def test_iteritems(dictionary):
from openpyxl.compat import iteritems
d = dictionary
assert set(iteritems(d)) == set([(3, 'd'), ('1', 1), ('a', 'b')])
def test_itervalues(dictionary):
from openpyxl.compat import itervalues
d = dictionary
assert set(itervalues(d)) == set([1, 'b', 'd'])
from .. import deprecated
def test_deprecated_function(recwarn):
@deprecated("no way")
def fn():
return "Hello world"
fn()
w = recwarn.pop()
assert issubclass(w.category, UserWarning)
assert w.filename
assert w.lineno
assert "no way" in str(w.message)
def test_deprecated_class(recwarn):
@deprecated("")
class Simple:
pass
s = Simple()
w = recwarn.pop()
assert issubclass(w.category, UserWarning)
assert w.filename
assert w.lineno
def test_deprecated_method(recwarn):
class Simple:
@deprecated("")
def do(self):
return "Nothing"
s = Simple()
s.do()
w = recwarn.pop()
assert issubclass(w.category, UserWarning)
assert w.filename
assert w.lineno
def test_no_deprecation_reason():
with pytest.raises(TypeError):
@deprecated
def fn():
return
|