TST: Convert assertEqual to regular asserts.

parent 83848e5d
......@@ -72,7 +72,7 @@ class BaseTestText(BaseTest):
return file_descriptor.read().strip()
def _test_equal(self, output, expected_output):
self.assertEqual(output, expected_output)
assert output == expected_output
class BaseTestDigit(BaseTestText):
......@@ -106,13 +106,13 @@ class BaseTestWordBox(BaseTestBox):
def _test_equal(self, output, expected_output):
self.assertTrue(len(output) > 0)
self.assertEqual(len(output), len(expected_output))
assert len(output) == len(expected_output)
for i in range(0, min(len(output), len(expected_output))):
self.assertTrue(isinstance(expected_output[i].content,
six.text_type))
self.assertTrue(isinstance(output[i].content, six.text_type))
self.assertEqual(output[i], expected_output[i])
assert output[i] == expected_output[i]
class BaseTestLineBox(BaseTestBox):
......@@ -120,15 +120,15 @@ class BaseTestLineBox(BaseTestBox):
self._builder = builders.LineBoxBuilder()
def _test_equal(self, output, expected_output):
self.assertEqual(len(output), len(expected_output))
assert len(output) == len(expected_output)
for i in range(0, min(len(output), len(expected_output))):
self.assertEqual(len(output[i].word_boxes),
len(expected_output[i].word_boxes))
assert (len(output[i].word_boxes) ==
len(expected_output[i].word_boxes))
for j in range(0, len(output[i].word_boxes)):
self.assertEqual(type(output[i].word_boxes[j]),
type(expected_output[i].word_boxes[j]))
self.assertEqual(output[i], expected_output[i])
assert (type(output[i].word_boxes[j]) ==
type(expected_output[i].word_boxes[j]))
assert output[i] == expected_output[i]
class BaseTestDigitLineBox(BaseTestLineBox):
......
......@@ -20,9 +20,7 @@ class TestContext(unittest.TestCase):
"cuneiform not found. Is it installed ?")
def test_version(self):
self.assertEqual(cuneiform.get_version(), (1, 1, 0),
("cuneiform does not have the expected version"
" (1.1.0) ! Tests will fail !"))
assert cuneiform.get_version() == (1, 1, 0)
def test_langs(self):
langs = cuneiform.get_available_languages()
......@@ -122,9 +120,9 @@ class TestWordBox(base.BaseTestWordBox, BaseCuneiform, unittest.TestCase):
with codecs.open(tmp_path, 'r', encoding='utf-8') as file_desc:
new_boxes = self._builder.read_file(file_desc)
self.assertEqual(len(new_boxes), len(original_boxes))
assert len(new_boxes) == len(original_boxes)
for i in range(0, len(original_boxes)):
self.assertEqual(new_boxes[i], original_boxes[i])
assert new_boxes[i] == original_boxes[i]
finally:
os.remove(tmp_path)
......
......@@ -56,7 +56,7 @@ class TestContext(unittest.TestCase):
os.environ['TESSDATA_PREFIX'] = '/opt/tulipe'
try:
langs = libtesseract.get_available_languages()
self.assertEqual(langs, [])
assert langs == []
finally:
if tessdata_prefix == "":
os.environ['TESSDATA_PREFIX'] = ""
......@@ -169,9 +169,9 @@ class TestWordBox(base.BaseTestWordBox, BaseLibtesseract, unittest.TestCase):
with codecs.open(tmp_path, 'r', encoding='utf-8') as fdescriptor:
new_boxes = self._builder.read_file(fdescriptor)
self.assertEqual(len(new_boxes), len(original_boxes))
assert len(new_boxes) == len(original_boxes)
for i in range(0, len(original_boxes)):
self.assertEqual(new_boxes[i], original_boxes[i])
assert new_boxes[i] == original_boxes[i]
finally:
os.remove(tmp_path)
......@@ -208,9 +208,9 @@ class TestLineBox(base.BaseTestLineBox, BaseLibtesseract, unittest.TestCase):
with codecs.open(tmp_path, 'r', encoding='utf-8') as fdescriptor:
new_boxes = self._builder.read_file(fdescriptor)
self.assertEqual(len(new_boxes), len(original_boxes))
assert len(new_boxes) == len(original_boxes)
for i in range(0, len(original_boxes)):
self.assertEqual(new_boxes[i], original_boxes[i])
assert new_boxes[i] == original_boxes[i]
finally:
os.remove(tmp_path)
......@@ -231,12 +231,12 @@ class TestOrientation(BaseLibtesseract, unittest.TestCase):
def test_orientation_0(self):
img = base.Image.open(self._path_to_img("test.png"))
result = libtesseract.detect_orientation(img, lang='eng')
self.assertEqual(result['angle'], 0)
assert result['angle'] == 0
def test_orientation_90(self):
img = base.Image.open(self._path_to_img("test-90.png"))
result = libtesseract.detect_orientation(img, lang='eng')
self.assertEqual(result['angle'], 90)
assert result['angle'] == 90
class TestBasicDoc(base.BaseTestLineBox, unittest.TestCase):
......
......@@ -92,10 +92,10 @@ class TestCharBox(base.BaseTestBox, BaseTesseract, unittest.TestCase):
self._builder = tesseract.CharBoxBuilder()
def _test_equal(self, output, expected_output):
self.assertEqual(len(output), len(expected_output))
assert len(output) == len(expected_output)
for i in range(0, min(len(output), len(expected_output))):
self.assertEqual(output[i], expected_output[i])
assert output[i] == expected_output[i]
def test_basic(self):
self._test_txt('test.png', 'test.box')
......@@ -125,9 +125,9 @@ class TestCharBox(base.BaseTestBox, BaseTesseract, unittest.TestCase):
with codecs.open(tmp_path, 'r', encoding='utf-8') as fdescriptor:
new_boxes = self._builder.read_file(fdescriptor)
self.assertEqual(len(new_boxes), len(original_boxes))
assert len(new_boxes) == len(original_boxes)
for i in range(0, len(original_boxes)):
self.assertEqual(new_boxes[i], original_boxes[i])
assert new_boxes[i] == original_boxes[i]
finally:
os.remove(tmp_path)
......@@ -172,9 +172,9 @@ class TestWordBox(base.BaseTestWordBox, BaseTesseract, unittest.TestCase):
with codecs.open(tmp_path, 'r', encoding='utf-8') as fdescriptor:
new_boxes = self._builder.read_file(fdescriptor)
self.assertEqual(len(new_boxes), len(original_boxes))
assert len(new_boxes) == len(original_boxes)
for i in range(0, len(original_boxes)):
self.assertEqual(new_boxes[i], original_boxes[i])
assert new_boxes[i] == original_boxes[i]
finally:
os.remove(tmp_path)
......@@ -212,9 +212,9 @@ class TestLineBox(base.BaseTestLineBox, BaseTesseract, unittest.TestCase):
with codecs.open(tmp_path, 'r', encoding='utf-8') as fdescriptor:
new_boxes = self._builder.read_file(fdescriptor)
self.assertEqual(len(new_boxes), len(original_boxes))
assert len(new_boxes) == len(original_boxes)
for i in range(0, len(original_boxes)):
self.assertEqual(new_boxes[i], original_boxes[i])
assert new_boxes[i] == original_boxes[i]
finally:
os.remove(tmp_path)
......@@ -238,12 +238,12 @@ class TestOrientation(BaseTesseract, unittest.TestCase):
def test_orientation_0(self):
img = base.Image.open(self._path_to_img("test.png"))
result = tesseract.detect_orientation(img, lang='eng')
self.assertEqual(result['angle'], 0)
assert result['angle'] == 0
def test_orientation_90(self):
img = base.Image.open(self._path_to_img("test-90.png"))
result = tesseract.detect_orientation(img, lang='eng')
self.assertEqual(result['angle'], 90)
assert result['angle'] == 90
def get_all_tests():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment