summaryrefslogtreecommitdiff
path: root/tests/run/importfrom.pyx
blob: a3e5de78df1443ce9968d887dbef4112a6fe4641 (plain)
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
from distutils import cmd, core, version

def import1():
    """
    >>> import1() == (cmd, core, version)
    True
    """
    from distutils import (

        cmd,

core,                    version)
    return cmd, core, version


def import2():
    """
    >>> import2() == (cmd, core, version)
    True
    """
    from distutils import (cmd,

core,


                           version
)
    return cmd, core, version


def import3():
    """
    >>> import3() == (cmd, core, version)
    True
    """
    from distutils import (cmd, core,version)
    return cmd, core, version

def import4():
    """
    >>> import4() == (cmd, core, version)
    True
    """
    from distutils import cmd, core, version
    return cmd, core, version



def typed_imports():
    """
    >>> typed_imports()
    True
    True
    an integer is required
    Expected type, got int
    """

    import sys
    import types
    cdef long maxunicode
    cdef type t

    from sys import maxunicode
    print(maxunicode == sys.maxunicode)
    from types import ModuleType as t
    print(t is types.ModuleType)

    try:
        from sys import version_info as maxunicode
    except TypeError, e:
        if getattr(sys, "pypy_version_info", None):
            # translate message
            if e.args[0].startswith("int() argument must be"):
                e = "an integer is required"
        print(e)

    try:
        from sys import maxunicode as t
    except TypeError, e:
        print(e)