def test_properly_gathers_all_input_and_output_values_of_a_function_call(self): self._init_project("def function(x):\n return x + 1\n", "from module import function\nfunction(42)\n") inspect_point_of_entry(self.poe) assert_length(self.project["module"].functions, 1) assert_length(self.project["module"].functions[0].calls, 1) assert_call({'x': 42}, 43, self.project["module"].functions[0].calls[0])
def test_properly_gathers_all_input_and_output_values_of_a_function_call(self): self._init_project("def function(x):\n return x + 1\n", "from module import function\nfunction(42)\n") inspect_point_of_entry(self.poe) assert_length(self.project["module"].functions, 1) assert_length(self.project["module"].functions[0].calls, 1) assert_call({'x': 42}, 43, self.project["module"].functions[0].calls[0])
def test_properly_gathers_all_input_and_output_values_of_a_method_call(self): self._init_project("class SomeClass:\n def some_method(self, x): return x + 1\n", "from module import SomeClass\nSomeClass().some_method(42)\n") method = Method("some_method") klass = Class("SomeClass", methods=[method]) self.project["module"].objects = [klass] inspect_point_of_entry(self.poe) user_object = assert_one_element_and_return(klass.user_objects) call = assert_one_element_and_return(user_object.calls) assert_call({'x': 42}, 43, call)
def test_properly_gathers_all_input_and_output_values_of_a_method_call(self): self._init_project("class SomeClass:\n def some_method(self, x): return x + 1\n", "from module import SomeClass\nSomeClass().some_method(42)\n") method = Method("some_method") klass = Class("SomeClass", methods=[method]) self.project["module"].objects = [klass] inspect_point_of_entry(self.poe) user_object = assert_one_element_and_return(klass.user_objects) call = assert_one_element_and_return(user_object.calls) assert_call({'x': 42}, 43, call)
def inspect_project_dynamically(project): if project.points_of_entry and hasattr(generator_has_ended, 'unreliable'): log.warning("Pure Python implementation of util.generator_has_ended is " "not reliable on Python 2.4 and lower. Please compile the " "_util module or use Python 2.5 or higher.") for poe in project.points_of_entry.values(): try: log.info("Inspecting point of entry %s." % poe.name) dynamic.inspect_point_of_entry(poe) except SyntaxError, err: log.warning("Point of entry contains a syntax error: %s" % err) except:
def inspect_project_dynamically(project): if project.points_of_entry and hasattr(generator_has_ended, 'unreliable'): log.warning( "Pure Python implementation of util.generator_has_ended is " "not reliable on Python 2.4 and lower. Please compile the " "_util module or use Python 2.5 or higher.") for poe in project.points_of_entry.values(): try: log.info("Inspecting point of entry %s." % poe.name) dynamic.inspect_point_of_entry(poe) except SyntaxError, err: log.warning("Point of entry contains a syntax error: %s" % err) except:
def test_changes_current_directory_to_the_projects_root(self): project = ProjectInDirectory(self.tmpdir) poe = PointOfEntryMock(project, content="import os; assert os.getcwd() == '%s'" % project.path) assert_not_raises(AssertionError, lambda: inspect_point_of_entry(poe))
def test_properly_wipes_out_imports_from_sys_modules(self): self._init_project(poe_content="import module") inspect_point_of_entry(self.poe) assert 'module' not in sys.modules
def test_changes_current_directory_to_the_projects_root(self): project = ProjectInDirectory(self.tmpdir) poe = PointOfEntryMock(project, content="import os; assert os.getcwd() == '%s'" % project.path) assert_not_raises(AssertionError, lambda: inspect_point_of_entry(poe))
def test_properly_wipes_out_imports_from_sys_modules(self): self._init_project(poe_content="import module") inspect_point_of_entry(self.poe) assert 'module' not in sys.modules