File: test_support_app.py

package info (click to toggle)
pypy3 7.0.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 111,848 kB
  • sloc: python: 1,291,746; ansic: 74,281; asm: 5,187; cpp: 3,017; sh: 2,533; makefile: 544; xml: 243; lisp: 45; csh: 21; awk: 4
file content (49 lines) | stat: -rw-r--r-- 1,509 bytes parent folder | download | duplicates (3)
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
"""App-level tests for support.py"""
import sys
import py

from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
from pypy.conftest import option

class AppTestSupport(BaseNumpyAppTest):
    def setup_class(cls):
        if option.runappdirect and '__pypy__' not in sys.builtin_module_names:
            py.test.skip("pypy only test")
        BaseNumpyAppTest.setup_class.im_func(cls)

    def test_add_docstring(self):
        import numpy as np
        foo = lambda: None
        np.add_docstring(foo, "Does a thing")
        assert foo.__doc__ == "Does a thing"

    def test_type_docstring(self):
        import numpy as np
        import types
        obj = types.ModuleType
        doc = obj.__doc__
        try:
            np.set_docstring(obj, 'foo')
            assert obj.__doc__ == 'foo'
        finally:
            np.set_docstring(obj, doc)

        raises(RuntimeError, np.add_docstring, obj, 'foo')

    def test_method_docstring(self):
        import numpy as np
        doc = int.bit_length.__doc__
        try:
            np.set_docstring(int.bit_length, 'foo')
            assert int.bit_length.__doc__ == 'foo'
        finally:
            np.set_docstring(int.bit_length, doc)

    def test_property_docstring(self):
        import numpy as np
        doc = np.flatiter.base.__doc__
        try:
            np.set_docstring(np.flatiter.base, 'foo')
            assert np.flatiter.base.__doc__ == 'foo'
        finally:
            np.set_docstring(np.flatiter.base, doc)