MCPcopy Create free account
hub / github.com/ActiveState/code / test

Function test

recipes/Python/550804_Create_restricted/recipe-550804.py:119–223  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117##################################################################
118### Some tests
119def test():
120 # -----------------------------------------------------
121 # Code to execute as function 'f' (as a string):
122 s = """
123if a == "BE RECURSIVE":
124 print "In the recursion 1"
125 return __TheFunction__("THE END", 54)
126elif a == "THE END":
127 print "In the recursion 2"
128 return 54
129
130print a
131print b
132x = True
133
134def sayhello(s):
135 print "I say hello that way: %s" % s
136
137class SayHello(object):
138 def __init__(self, s):
139 self.__s = s
140 print "ctor says %s" % self.__s
141
142 def s(self):
143 return self.__s
144try:
145 1/0
146except ZeroDivisionError, ex:
147 print "GOT EX", ex
148
149print "ooo in here says", ooo.mouf()
150
151result = a + b +1
152afunction(a+1)
153c = re.compile("^a").search("ba", 1)
154d = re.compile("a").match("ba", 1)
155sayhello("I am so happy today %s,%s" % (c, d))
156o = SayHello("this works")
157vvv = range(42)
158print vvv
159sys.stderr.write("writing to stderr\\n")
160
161print __TheFunction__
162print "============ BEGIN docstring ==========="
163print __TheFunction__.__doc__
164print "============ END docstring ==========="
165return a*b + __TheFunction__("BE RECURSIVE", 33)
166"""
167 # End of source code string
168 # -----------------------------------------------------
169
170 # Create objects, functions, etc.
171 class OOO:
172 def __init__(self, id):
173 self.__id = id
174 def mouf(self):
175 return "OOO: My ID is %s" % self.__id
176 def F(n):

Callers

nothing calls this directly

Calls 9

OOOClass · 0.85
createFunctionFunction · 0.85
xrangeClass · 0.85
nothingFunction · 0.85
dictFunction · 0.50
fFunction · 0.50
gFunction · 0.50
sleepMethod · 0.45
timeMethod · 0.45

Tested by

no test coverage detected