From 864fea804c0a04098d0a269dbed84c4582d26128 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Sat, 27 Apr 2024 12:32:44 +0200 Subject: [PATCH 1/2] remove needless six usage --- tests/test_model.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/test_model.py b/tests/test_model.py index 87033d5..6edc426 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -22,7 +22,7 @@ import tempfile import unittest -from six import u, StringIO, BytesIO +from six import StringIO, BytesIO from firehose.model import Analysis, Issue, Metadata, Generator, SourceRpm, \ Location, File, Function, Point, Message, Notes, Trace, State, Stats, \ @@ -333,7 +333,7 @@ def test_example_6(self): def test_non_ascii_example(self): with open('examples/example-non-ascii.xml') as f: a = Analysis.from_xml(f) - self.assertEqual(a.metadata.generator.name, u('\u2620') * 8) + self.assertEqual(a.metadata.generator.name, u'\u2620' * 8) self.assertEqual(len(a.results), 1) w = a.results[0] @@ -343,15 +343,15 @@ def test_non_ascii_example(self): # "comparison between signed and unsigned integer expressions" # within the message: self.assertEqual(w.message.text, - (u('\u7b26\u53f7\u4ed8\u304d\u3068\u7b26\u53f7' - '\u7121\u3057\u306e\u6574\u6570\u5f0f\u306e' - '\u9593\u3067\u306e\u6bd4\u8f03\u3067\u3059'))) + (u'\u7b26\u53f7\u4ed8\u304d\u3068\u7b26\u53f7' + u'\u7121\u3057\u306e\u6574\u6570\u5f0f\u306e' + u'\u9593\u3067\u306e\u6bd4\u8f03\u3067\u3059')) # Verify the "mojibake" Kanji/Hiragana within the notes: - self.assertIn(u('\u6587\u5b57\u5316\u3051'), + self.assertIn(u'\u6587\u5b57\u5316\u3051', w.notes.text) - self.assertEqual(w.location.function.name, u('oo\u025f')) + self.assertEqual(w.location.function.name, u'oo\u025f') def test_to_xml(self): def validate(xmlbytes): From 49af0e5d2d6dbd201e937132ad9d69d0fef35cda Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Sat, 27 Apr 2024 12:33:58 +0200 Subject: [PATCH 2/2] prefer the newer unittest.mock on Python3 --- tests/parsers/test_frama_c_parser.py | 5 ++++- tests/parsers/test_gcc_parser.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/parsers/test_frama_c_parser.py b/tests/parsers/test_frama_c_parser.py index 4ac4227..fcd1a3e 100644 --- a/tests/parsers/test_frama_c_parser.py +++ b/tests/parsers/test_frama_c_parser.py @@ -1,6 +1,9 @@ import unittest -import mock +try: + from unittest import mock +except: + import mock from firehose.parsers import frama_c from firehose.model import Issue, Location, File, Point, \ diff --git a/tests/parsers/test_gcc_parser.py b/tests/parsers/test_gcc_parser.py index 8b4248e..c5ed54b 100644 --- a/tests/parsers/test_gcc_parser.py +++ b/tests/parsers/test_gcc_parser.py @@ -17,7 +17,10 @@ import unittest -import mock +try: + from unittest import mock +except ImportError: + import mock from firehose.parsers import gcc # import parse_warning, parse_file from firehose.model import Analysis, Issue, Location, File, Point, \