def test_static_initializer_and_multi_level_classpath(self): ret = findbugs.parse_line('H C NP: Null pointer dereference of l1_l2_so in l1.l2.Main.<static initializer for Main>() Dereferenced at Main.java:[line 7]') self.assertIsInstance(ret, Issue) self.assertIsInstance(ret.location, Location) self.assertEqual(ret.location.line, 7) self.assertIsInstance(ret.location.function, Function) self.assertEqual(ret.location.function.name, "<static initializer for Main>()") self.assertIsInstance(ret.location.file, File) self.assertEqual(ret.location.file.givenpath, "l1/l2/Main.java") self.assertIsInstance(ret.message, Message) self.assertEqual(ret.message.text, "H C NP: Null pointer dereference of l1_l2_so")
def test_no_class_path(self): ret = findbugs.parse_line('H C NP: Null pointer dereference of o in Main.main(String[]) Dereferenced at Main.java:[line 12]') self.assertIsInstance(ret, Issue) self.assertIsInstance(ret.location, Location) self.assertEqual(ret.location.line, 12) self.assertIsInstance(ret.location.function, Function) self.assertEqual(ret.location.function.name, "main(String[])") self.assertIsInstance(ret.location.file, File) self.assertEqual(ret.location.file.givenpath, "Main.java") self.assertIsInstance(ret.message, Message) self.assertEqual(ret.message.text, "H C NP: Null pointer dereference of o")
def test_testdata_jformatstring(self): for i in range(0,len(testdata_jformatstring_answer)): ret = findbugs.parse_line(testdata_jformatstring_array[i]) #print testdata_jformatstring_array[i] #print ret self.assertIsInstance(ret, Issue) self.assertIsInstance(ret.location, Location) #print ret.location.line, testdata_jformatstring_answer[i][0] self.assertEqual(ret.location.line, testdata_jformatstring_answer[i][0]) self.assertIsInstance(ret.location.function, Function) #print ret.location.function.name, testdata_jformatstring_answer[i][1] self.assertEqual(ret.location.function.name, testdata_jformatstring_answer[i][1]) self.assertIsInstance(ret.location.file, File) #print ret.location.file.givenpath, testdata_jformatstring_answer[i][2] self.assertEqual(ret.location.file.givenpath, testdata_jformatstring_answer[i][2]) self.assertIsInstance(ret.message, Message) #print ret.message.text, testdata_jformatstring_answer[i][3] self.assertEqual(ret.message.text, testdata_jformatstring_answer[i][3])
def test_new_line(self): ret = findbugs.parse_line('\n') self.assertTrue(ret is None)
def test_empty(self): ret = findbugs.parse_line('') self.assertTrue(ret is None)