/usr/lib/python2.7/dist-packages/openpyxl/compat/tests/test_compat.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 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 95 96 | from __future__ import absolute_import
# Copyright (c) 2010-2017 openpyxl
import pytest
import sys
@pytest.mark.parametrize("value, result",
[
('s', 's'),
(2.0/3, '0.6666666666666666'),
(1, '1'),
(None, 'none'),
(float('NaN'), ''),
]
)
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.mark.numpy_required
def test_numeric_types():
from ..numbers import NUMERIC_TYPES, numpy, Decimal, long
assert NUMERIC_TYPES == (int, float, long, Decimal, numpy.bool_,
numpy.floating, numpy.integer)
@pytest.mark.numpy_required
def test_numpy_tostring():
from numpy import float_, int_, bool_
from .. import safe_string
assert safe_string(float_(5.1)) == "5.1"
assert safe_string(int(5)) == "5"
assert safe_string(bool_(True)) == "1"
@pytest.mark.skipif("sys.version_info[0]>=3")
def test_safe_repr():
from ..strings import safe_repr
s = u"D\xfcsseldorf"
assert safe_repr(s) == s.encode("ascii", "backslashreplace")
from .. import deprecated
def test_deprecated_function(recwarn):
@deprecated("no way")
def fn():
return "Hello world"
fn()
w = recwarn.pop()
assert issubclass(w.category, DeprecationWarning)
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, DeprecationWarning)
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, DeprecationWarning)
assert w.filename
assert w.lineno
def test_no_deprecation_reason():
with pytest.raises(TypeError):
@deprecated
def fn():
return
|