def test_can_execute_on_own_code(self): output_path = os.path.join(self.tests_temp_folder, 'test_can_execute_on_own_code.txt') try: os.remove(output_path) except FileNotFoundError: pass # Ignore missing file as it is going to be recreated. command = Command() command.set_output(output_path) command.set_output_format('cloc-xml') command.set_source_patterns(self.pygount_folder) command.set_suffixes('py') command.execute() cloc_xml_root = ElementTree.parse(output_path) file_elements = cloc_xml_root.findall('files/file') self.assertIsNotNone(file_elements) self.assertNotEqual(len(file_elements), 0)
def test_can_execute_on_own_code(self): output_path = os.path.join(self.tests_temp_folder, 'test_can_execute_on_own_code.txt') try: os.remove(output_path) except FileNotFoundError: pass # Ignore missing file as it is going to be recreated. command = Command() command.set_output(output_path) command.set_output_format('cloc-xml') command.set_source_patterns(self.pygount_folder) command.set_suffices('py') command.execute() cloc_xml_root = ElementTree.parse(output_path) file_elements = cloc_xml_root.findall('files/file') self.assertIsNotNone(file_elements) self.assertNotEqual(len(file_elements), 0)
def test_can_execute_on_own_code(self): output_path = os.path.join(self.tests_temp_folder, "test_can_execute_on_own_code.txt") try: os.remove(output_path) except FileNotFoundError: pass # Ignore missing file as it is going to be recreated. command = Command() command.set_output(output_path) command.set_output_format("cloc-xml") command.set_source_patterns(_PYGOUNT_SOURCE_FOLDER) command.set_suffixes("py") command.execute() cloc_xml_root = ElementTree.parse(output_path) file_elements = cloc_xml_root.findall("files/file") assert file_elements is not None assert len(file_elements) >= 1
def test_fails_on_unknown_output_format(self): unknown_output_format = "no_such_output_format" command = Command() with pytest.raises(OptionError, match=unknown_output_format): command.set_output_format(unknown_output_format)