TST: Replace assertTrue/False with plain asserts.

parent 0f7e11a9
......@@ -105,13 +105,12 @@ class BaseTestWordBox(BaseTestBox):
self._builder = builders.WordBoxBuilder()
def _test_equal(self, output, expected_output):
self.assertTrue(len(output) > 0)
assert len(output) > 0
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))
assert isinstance(expected_output[i].content, six.text_type)
assert isinstance(output[i].content, six.text_type)
assert output[i] == expected_output[i]
......@@ -146,4 +145,4 @@ class BaseTestPdf(BaseTest):
return file_descriptor.read()
def _test_not_empty(self, output):
self.assertTrue(len(output) > 0)
assert len(output) > 0
......@@ -16,20 +16,15 @@ class TestContext(unittest.TestCase):
pass
def test_available(self):
self.assertTrue(cuneiform.is_available(),
"cuneiform not found. Is it installed ?")
assert cuneiform.is_available()
def test_version(self):
assert cuneiform.get_version() == (1, 1, 0)
def test_langs(self):
langs = cuneiform.get_available_languages()
self.assertTrue("eng" in langs,
("English training does not appear to be installed."
" (required for the tests)"))
self.assertTrue("fra" in langs,
("French training does not appear to be installed."
" (required for the tests)"))
assert "eng" in langs
assert "fra" in langs
def tearDown(self):
pass
......@@ -107,7 +102,7 @@ class TestWordBox(base.BaseTestWordBox, BaseCuneiform, unittest.TestCase):
original_boxes = self._read_from_img(
os.path.join("tests", "input", "specific", "test.png")
)
self.assertTrue(len(original_boxes) > 0)
assert len(original_boxes) > 0
(file_descriptor, tmp_path) = tempfile.mkstemp()
try:
......@@ -129,7 +124,7 @@ class TestWordBox(base.BaseTestWordBox, BaseCuneiform, unittest.TestCase):
class TestOrientation(unittest.TestCase):
def test_can_detect_orientation(self):
self.assertFalse(cuneiform.can_detect_orientation())
assert not cuneiform.can_detect_orientation()
def get_all_tests():
......
......@@ -20,36 +20,23 @@ class TestContext(unittest.TestCase):
pass
def test_available(self):
self.assertTrue(
libtesseract.is_available(),
"Tesseract not found."
" Are libtesseract and libleptonica installed ? "
)
assert libtesseract.is_available()
def test_version(self):
self.assertTrue(
libtesseract.get_version() in (
assert libtesseract.get_version() in (
(3, 2, 1),
(3, 2, 2),
(3, 3, 0),
(3, 4, 0),
(3, 4, 1),
(3, 5, 0),
),
("Tesseract does not have the expected version")
)
)
def test_langs(self):
langs = libtesseract.get_available_languages()
self.assertTrue("eng" in langs,
("English training does not appear to be installed."
" (required for the tests)"))
self.assertTrue("fra" in langs,
("French training does not appear to be installed."
" (required for the tests)"))
self.assertTrue("jpn" in langs,
("Japanese training does not appear to be installed."
" (required for the tests)"))
assert "eng" in langs
assert "fra" in langs
assert "jpn" in langs
def test_nolangs(self):
tessdata_prefix = os.getenv("TESSDATA_PREFIX", "")
......@@ -156,7 +143,7 @@ class TestWordBox(base.BaseTestWordBox, BaseLibtesseract, unittest.TestCase):
def test_write_read(self):
image_path = self._path_to_img("test.png")
original_boxes = self._read_from_img(image_path)
self.assertTrue(len(original_boxes) > 0)
assert len(original_boxes) > 0
(file_descriptor, tmp_path) = tempfile.mkstemp()
try:
......@@ -195,7 +182,7 @@ class TestLineBox(base.BaseTestLineBox, BaseLibtesseract, unittest.TestCase):
def test_write_read(self):
image_path = self._path_to_img("test.png")
original_boxes = self._read_from_img(image_path)
self.assertTrue(len(original_boxes) > 0)
assert len(original_boxes) > 0
(file_descriptor, tmp_path) = tempfile.mkstemp()
try:
......@@ -226,7 +213,7 @@ class TestOrientation(BaseLibtesseract, unittest.TestCase):
self._builder = builders.TextBuilder()
def test_can_detect_orientation(self):
self.assertTrue(libtesseract.can_detect_orientation())
assert libtesseract.can_detect_orientation()
def test_orientation_0(self):
img = base.Image.open(self._path_to_img("test.png"))
......
......@@ -17,33 +17,23 @@ class TestContext(unittest.TestCase):
pass
def test_available(self):
self.assertTrue(tesseract.is_available(),
"Tesseract not found. Is it installed ?")
assert tesseract.is_available()
def test_version(self):
self.assertTrue(
tesseract.get_version() in (
assert tesseract.get_version() in (
(3, 2, 1),
(3, 2, 2),
(3, 3, 0),
(3, 4, 0),
(3, 4, 1),
(3, 5, 0),
),
("Tesseract does not have the expected version")
)
)
def test_langs(self):
langs = tesseract.get_available_languages()
self.assertTrue("eng" in langs,
("English training does not appear to be installed."
" (required for the tests)"))
self.assertTrue("fra" in langs,
("French training does not appear to be installed."
" (required for the tests)"))
self.assertTrue("jpn" in langs,
("Japanese training does not appear to be installed."
" (required for the tests)"))
assert "eng" in langs
assert "fra" in langs
assert "jpn" in langs
def tearDown(self):
pass
......@@ -112,7 +102,7 @@ class TestCharBox(base.BaseTestBox, BaseTesseract, unittest.TestCase):
def test_write_read(self):
image_path = self._path_to_img("test.png")
original_boxes = self._read_from_img(image_path)
self.assertTrue(len(original_boxes) > 0)
assert len(original_boxes) > 0
(file_descriptor, tmp_path) = tempfile.mkstemp()
try:
......@@ -159,7 +149,7 @@ class TestWordBox(base.BaseTestWordBox, BaseTesseract, unittest.TestCase):
def test_write_read(self):
image_path = self._path_to_img("test.png")
original_boxes = self._read_from_img(image_path)
self.assertTrue(len(original_boxes) > 0)
assert len(original_boxes) > 0
(file_descriptor, tmp_path) = tempfile.mkstemp()
try:
......@@ -199,7 +189,7 @@ class TestLineBox(base.BaseTestLineBox, BaseTesseract, unittest.TestCase):
def test_write_read(self):
image_path = self._path_to_img("test.png")
original_boxes = self._read_from_img(image_path)
self.assertTrue(len(original_boxes) > 0)
assert len(original_boxes) > 0
(file_descriptor, tmp_path) = tempfile.mkstemp()
try:
......@@ -233,7 +223,7 @@ class TestOrientation(BaseTesseract, unittest.TestCase):
self._builder = builders.TextBuilder()
def test_can_detect_orientation(self):
self.assertTrue(tesseract.can_detect_orientation())
assert tesseract.can_detect_orientation()
def test_orientation_0(self):
img = base.Image.open(self._path_to_img("test.png"))
......
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