File: test_limitations.py

package info (click to toggle)
xdoctest 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,512 kB
  • sloc: python: 10,963; sh: 815; cpp: 33; makefile: 19
file content (42 lines) | stat: -rw-r--r-- 1,188 bytes parent folder | download
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
"""
Tests in this file are more demonstrations of the limitations of the static
analysis doctest parser.
"""
from xdoctest import utils
from xdoctest.utils.util_misc import _run_case


def test_pathological_property_case():
    """
    This case actually wont error, but it displays a limitation of static
    analysis. We trick the doctest node parser into thinking there is a setter
    property when there really isn't.
    """
    text = _run_case(utils.codeblock(
        '''
        def property(x):
            class Foo():
                def setter(self, x):
                    return x
            return Foo()

        class Test:
            @property
            def test(self):
                """
                Example:
                    >>> print('not really a getter')
                """
                return 3.14

            @test.setter
            def test(self, s):
                """
                Example:
                    >>> print('not really a setter')
                """
                pass
        '''))
    # If there was a way to make this case fail, that would be ok
    assert 'Test.test:0' in text
    # assert 'Test.test.fset:0' in text