1# ticket: 87
2
3__doc__ = u"""
4>>> d = Defined()
5>>> n = NotDefined()         # doctest: +ELLIPSIS
6Traceback (most recent call last):
7NameError: ...name 'NotDefined' is not defined
8"""
9
10if True:
11    class Defined(object):
12        """
13        >>> isinstance(Defined(), Defined)
14        True
15        """
16
17if False:
18    class NotDefined(object):
19        """
20        >>> NotDefined() # fails when defined
21        """
22
23def test_class_cond(x):
24    """
25    >>> Test, test = test_class_cond(True)
26    >>> test.A
27    1
28    >>> Test().A
29    1
30    >>> Test, test = test_class_cond(False)
31    >>> test.A
32    2
33    >>> Test().A
34    2
35    """
36    if x:
37        class Test(object):
38            A = 1
39    else:
40        class Test(object):
41            A = 2
42    return Test, Test()
43
44def test_func_cond(x):
45    """
46    >>> func = test_func_cond(True)
47    >>> func()
48    1
49    >>> func = test_func_cond(False)
50    >>> func()
51    2
52    """
53    if x:
54        def func():
55            return 1
56    else:
57        def func():
58            return 2
59    return func
60