def setUp(self): func_call1 = FunctionCall.from_function(simple) func_call2 = FunctionCall.from_function(with_defaults) self.statements = [func_call1,func_call2] unittest.TestCase.setUp(self)
def setUp(self): func_call1 = FunctionCall.from_function(simple) func_call2 = FunctionCall.from_function(with_defaults) self.statements = [func_call1, func_call2] unittest.TestCase.setUp(self)
def _test_py_modules_in_directory(self, lib_dir): py_files = glob(os.path.join(lib_dir,'*.py')) module_names = [] for path in py_files: base_name = os.path.basename(path) module_name, ext = os.path.splitext(base_name) module_names.append(module_name) for module_name in module_names: # fixme: do this with pkgutil? try: # Skip modules that don't import. Since not all modules # in the standard library will import on all platforms. exec "import %s" % module_name module = eval(module_name) except ImportError: module = None if module: functions = _get_functions(module) for function in functions: func = FunctionCall.from_function(function) signature = func.call_signature
def test_simple(self): func_call = FunctionCall.from_function(simple) inputs = func_call.inputs # Check the names. desired = ['a','b'] self.assertEqual([x.name for x in inputs], desired) # And the default values. desired = [None, None] self.assertEqual([x.default for x in inputs], desired) # And the values values. desired = ['a', 'b'] self.assertEqual([x.binding for x in inputs], desired) # Now check the output names. outputs = [x.name for x in func_call.outputs] desired = ['x','y'] self.assertEqual(outputs, desired) # Check the module. # fixme: Do we actually want to test this here? I think only if # we choose to move module up to the func_call level. desired = simple.__module__ self.assertEqual(func_call.function.module, desired)
def test_unbound_default_call_signature(self): func = FunctionCall.from_function(with_defaults) desired = 'x, y = with_defaults(a, b=b)' self.assertEqual(func.call_signature, desired)
def test_simple(self): func_call = FunctionCall.from_function(simple) inputs = func_call.inputs # Check the names. desired = ['a', 'b'] self.assertEqual([x.name for x in inputs], desired) # And the default values. desired = [None, None] self.assertEqual([x.default for x in inputs], desired) # And the values values. desired = ['a', 'b'] self.assertEqual([x.binding for x in inputs], desired) # Now check the output names. outputs = [x.name for x in func_call.outputs] desired = ['x', 'y'] self.assertEqual(outputs, desired) # Check the module. # fixme: Do we actually want to test this here? I think only if # we choose to move module up to the func_call level. desired = simple.__module__ self.assertEqual(func_call.function.module, desired)
def _test_py_modules_in_directory(self, lib_dir): py_files = glob(os.path.join(lib_dir, '*.py')) module_names = [] for path in py_files: base_name = os.path.basename(path) module_name, ext = os.path.splitext(base_name) module_names.append(module_name) for module_name in module_names: # fixme: do this with pkgutil? try: # Skip modules that don't import. Since not all modules # in the standard library will import on all platforms. exec "import %s" % module_name module = eval(module_name) except ImportError: module = None if module: functions = _get_functions(module) for function in functions: func = FunctionCall.from_function(function) signature = func.call_signature
def test_no_return(self): func = FunctionCall.from_function(no_return) # Now check the output names. outputs = [x.name for x in func.outputs] desired = [] self.assertEqual(outputs, desired)
def test_label_name(self): func = FunctionCall.from_function(simple) self.assertEqual(func.label_name, "simple") func.function.name = "no_return" self.assertEqual(func.label_name, "no_return") func.function.library_name = "foo" self.assertEqual(func.label_name, "foo")
def test_name_change_updates_call_signature(self): func = FunctionCall.from_function(simple) desired = 'x, y = simple(a, b)' self.assertEqual(func.call_signature, desired) func.label_name = 'baz' desired = 'x, y = baz(a, b)' self.assertEqual(func.call_signature, desired)
def test_label_name(self): func = FunctionCall.from_function(simple) self.assertEqual(func.label_name,"simple") func.function.name = "no_return" self.assertEqual(func.label_name, "no_return") func.function.library_name = "foo" self.assertEqual(func.label_name,"foo")
def test_with_defaults_none(self): func = FunctionCall.from_function(with_defaults_none) inputs = func.inputs # Check the names. desired = ['a', 'b'] self.assertEqual([x.name for x in inputs], desired) # And the default values. desired = [None, 'None'] self.assertEqual([x.default for x in inputs], desired)
def test_with_defaults_none(self): func = FunctionCall.from_function(with_defaults_none) inputs = func.inputs # Check the names. desired = ['a','b'] self.assertEqual([x.name for x in inputs], desired) # And the default values. desired = [None, 'None'] self.assertEqual([x.default for x in inputs], desired)
def test_with_defaults(self): func = FunctionCall.from_function(with_defaults) inputs = func.inputs # Check the names. desired = ['a','b'] self.assertEqual([x.name for x in inputs], desired) # And the default values. desired = [None, '3'] self.assertEqual([x.default for x in inputs], desired) # Now check the output names. outputs = [x.name for x in func.outputs] desired = ['x','y'] self.assertEqual(outputs, desired)
def test_with_defaults(self): func = FunctionCall.from_function(with_defaults) inputs = func.inputs # Check the names. desired = ['a', 'b'] self.assertEqual([x.name for x in inputs], desired) # And the default values. desired = [None, '3'] self.assertEqual([x.default for x in inputs], desired) # Now check the output names. outputs = [x.name for x in func.outputs] desired = ['x', 'y'] self.assertEqual(outputs, desired)
def test_simple_call_signature(self): func = FunctionCall.from_function(simple) desired = 'x, y = simple(a, b)' self.assertEqual(func.call_signature, desired)
def test_empty_return_call_signature(self): func = FunctionCall.from_function(empty_return) desired = 'empty_return(a, b)' self.assertEqual(func.call_signature, desired)