~ubuntu-branches/debian/experimental/nuitka/experimental

« back to all changes in this revision

Viewing changes to tests/basics/Referencing_2.py

  • Committer: Package Import Robot
  • Author(s): Kay Hayen
  • Date: 2014-10-05 19:28:20 UTC
  • mfrom: (1.1.30)
  • Revision ID: package-import@ubuntu.com-20141005192820-s06oca9rty517iy8
Tags: 0.5.5+ds-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#     Copyright 2014, Kay Hayen, mailto:kay.hayen@gmail.com
 
2
#
 
3
#     Python tests originally created or extracted from other peoples work. The
 
4
#     parts were too small to be protected.
 
5
#
 
6
#     Licensed under the Apache License, Version 2.0 (the "License");
 
7
#     you may not use this file except in compliance with the License.
 
8
#     You may obtain a copy of the License at
 
9
#
 
10
#        http://www.apache.org/licenses/LICENSE-2.0
 
11
#
 
12
#     Unless required by applicable law or agreed to in writing, software
 
13
#     distributed under the License is distributed on an "AS IS" BASIS,
 
14
#     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
15
#     See the License for the specific language governing permissions and
 
16
#     limitations under the License.
 
17
#
 
18
import sys, os
 
19
 
 
20
# Find common code relative in file system. Not using packages for test stuff.
 
21
sys.path.insert(
 
22
    0,
 
23
    os.path.normpath(
 
24
        os.path.join(
 
25
            os.path.dirname(os.path.abspath(__file__)),
 
26
            ".."
 
27
        )
 
28
    )
 
29
)
 
30
from test_common import (
 
31
    executeReferenceChecked,
 
32
    checkReferenceCount,
 
33
    my_print,
 
34
)
 
35
 
 
36
if not hasattr(sys, "gettotalrefcount"):
 
37
    my_print("Warning, using non-debug Python makes this test ineffective.")
 
38
    sys.gettotalrefcount = lambda : 0
 
39
 
 
40
x = 17
 
41
 
 
42
# Python2 only syntax things are here.
 
43
def simpleFunction1():
 
44
    try:
 
45
        raise TypeError, (3,x,x,x)
 
46
    except TypeError:
 
47
        pass
 
48
 
 
49
def simpleFunction2():
 
50
    try:
 
51
        raise ValueError(1,2,3), ValueError(1,2,3)
 
52
    except Exception:
 
53
        pass
 
54
 
 
55
def simpleFunction3():
 
56
    try:
 
57
        raise ValueError, 2, None
 
58
    except Exception:
 
59
        pass
 
60
 
 
61
def simpleFunction4():
 
62
    try:
 
63
        raise ValueError, 2, 3
 
64
    except Exception:
 
65
        pass
 
66
 
 
67
def simpleFunction5():
 
68
    def nested_args_function((a,b), c):
 
69
        return a, b, c
 
70
 
 
71
    nested_args_function((1, 2), 3)
 
72
 
 
73
def simpleFunction6():
 
74
    def nested_args_function((a,b), c):
 
75
        return a, b, c
 
76
 
 
77
    try:
 
78
        nested_args_function((1,), 3)
 
79
    except ValueError:
 
80
        pass
 
81
 
 
82
def simpleFunction7():
 
83
    def nested_args_function((a,b), c):
 
84
        return a, b, c
 
85
 
 
86
    try:
 
87
        nested_args_function((1, 2, 3), 3)
 
88
    except ValueError:
 
89
        pass
 
90
 
 
91
 
 
92
# These need stderr to be wrapped.
 
93
tests_stderr = ()
 
94
 
 
95
# Disabled tests
 
96
tests_skipped = {}
 
97
 
 
98
result = executeReferenceChecked(
 
99
    prefix        = "simpleFunction",
 
100
    names         = globals(),
 
101
    tests_skipped = tests_skipped,
 
102
    tests_stderr  = tests_stderr
 
103
)
 
104
 
 
105
sys.exit(0 if result else 1)