Show More
@@ -593,5 +593,17 class TestView(ClusterTestCase, ParametricTestCase): | |||||
593 | self.assertTrue("data" in output) |
|
593 | self.assertTrue("data" in output) | |
594 | data = output['data'] |
|
594 | data = output['data'] | |
595 | self.assertTrue("image/png" in data) |
|
595 | self.assertTrue("image/png" in data) | |
|
596 | ||||
|
597 | def test_func_default_func(self): | |||
|
598 | """interactively defined function as apply func default""" | |||
|
599 | def foo(): | |||
|
600 | return 'foo' | |||
|
601 | ||||
|
602 | def bar(f=foo): | |||
|
603 | return f() | |||
596 |
|
604 | |||
|
605 | view = self.client[-1] | |||
|
606 | ar = view.apply_async(bar) | |||
|
607 | r = ar.get(10) | |||
|
608 | self.assertEquals(r, 'foo') | |||
597 |
|
609 |
@@ -84,7 +84,10 class CannedFunction(CannedObject): | |||||
84 | def __init__(self, f): |
|
84 | def __init__(self, f): | |
85 | self._check_type(f) |
|
85 | self._check_type(f) | |
86 | self.code = f.func_code |
|
86 | self.code = f.func_code | |
87 |
|
|
87 | if f.func_defaults: | |
|
88 | self.defaults = [ can(fd) for fd in f.func_defaults ] | |||
|
89 | else: | |||
|
90 | self.defaults = None | |||
88 | self.module = f.__module__ or '__main__' |
|
91 | self.module = f.__module__ or '__main__' | |
89 | self.__name__ = f.__name__ |
|
92 | self.__name__ = f.__name__ | |
90 | self.buffers = [] |
|
93 | self.buffers = [] | |
@@ -104,7 +107,11 class CannedFunction(CannedObject): | |||||
104 |
|
107 | |||
105 | if g is None: |
|
108 | if g is None: | |
106 | g = {} |
|
109 | g = {} | |
107 | newFunc = FunctionType(self.code, g, self.__name__, self.defaults) |
|
110 | if self.defaults: | |
|
111 | defaults = tuple(uncan(cfd, g) for cfd in self.defaults) | |||
|
112 | else: | |||
|
113 | defaults = None | |||
|
114 | newFunc = FunctionType(self.code, g, self.__name__, defaults) | |||
108 | return newFunc |
|
115 | return newFunc | |
109 |
|
116 | |||
110 |
|
117 |
General Comments 0
You need to be logged in to leave comments.
Login now