Beispiel #1
0
 def test_convert_function_proper_docstring(self):
     html1 = get_html_from_function_info(PythonFunctionInfo.from_function(proper_func1))
     html2 = get_html_from_function_info(PythonFunctionInfo.from_function(proper_func2))
     # If [unit] is in the html, it has properly identified by
     # convert_function
     self.assertNotEqual(html1.find('[km/s]'), -1)
     self.assertNotEqual(html2.find('[g/cc]'), -1)
Beispiel #2
0
 def test_platform_specific(self):
     html = get_html_from_function_info(PythonFunctionInfo.from_function(proper_func1))
     p = platform.system()
     if p == 'Windows':
         self.assertNotEqual(html.find('<style'), -1)
     else:
         self.assertEqual(html.find('<style'), -1)
    def test_code(self):
        func = PythonFunctionInfo.from_function(simple)
        correct_code = """def simple(a,b):
    x,y=a,b
    return x,y
"""
        self.assertEqual(func.code, correct_code)
    def test_change_library_name(self):
        func = PythonFunctionInfo.from_function(simple)

        self.assertEqual(func.name, 'simple')
        self.assertEqual(func.library_name, 'simple')

        func.library_name = 'foo'
        self.assertEqual(func.name, 'simple')
        self.assertEqual(func.library_name, 'foo')
    def test_with_defaults_none(self):
        func = PythonFunctionInfo.from_function(with_defaults_none)

        # Check the inputs.
        inputs = func.inputs
        desired = (('a', None), ('b', 'None'))
        self._check_input(inputs, desired)

        # Now check the output names.
        outputs = func.outputs
        desired = ('x','y')
        self._check_output(outputs, desired)
Beispiel #6
0
 def test_convert_function_bad_docstring(self):
     html = get_html_from_function_info(PythonFunctionInfo.from_function(bad_func1))
     self.assertEqual(html.find('Parameters'), -1)
 def test_empty(self):
     """ Can we handle a function without any inputs/outputs?
     """
     func = PythonFunctionInfo.from_function(empty)
     self.assertEqual(func.doc_string, "")