File: test_support_app.py

package info (click to toggle)
pypy3 7.3.19%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 212,236 kB
  • sloc: python: 2,098,316; ansic: 540,565; sh: 21,462; asm: 14,419; cpp: 4,451; makefile: 4,209; objc: 761; xml: 530; exp: 499; javascript: 314; pascal: 244; lisp: 45; csh: 12; awk: 4
file content (49 lines) | stat: -rw-r--r-- 1,515 bytes parent folder | download | duplicates (5)
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(np.ndarray.shape, 'foo')
            assert np.ndarray.shape.__doc__ == 'foo'
        finally:
            np.set_docstring(np.ndarray.shape, 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)