commit 8993514576ca932cc88bc87fd369312e6f6cf8d5 Author: vaydheesh Date: Thu Aug 1 11:29:16 2019 +0530 tests: use inbuilt methods for assertion diff --git a/tests/__init__.py b/tests/__init__.py index 469a698..6b587b0 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -75,28 +75,19 @@ class TestGenerate(unittest.TestCase): class TestInstallation(unittest.TestCase): def test_apertium_base(self): apertium.installer.install_apertium() - apertium_exists = False - if shutil.which('lt-proc'): - apertium_exists = True - self.assertTrue(apertium_exists, 'apertium binaries not find') + self.assertIsNotNone(shutil.which('lt-proc'), 'apertium binaries not installed') def test_install_module(self): - apertium.installer.install_module('kir') + language = 'kir' + apertium.installer.install_module(language) importlib.reload(apertium) - try: - apertium.analyze('kir', 'cats') - except apertium.ModeNotInstalled: - self.fail('apetium.install_module not working') + self.assertIn(language, apertium.analyzers, 'apetium.install_module not working') def test_install_wrapper(self): apertium.installer.install_wrapper('python3-lttoolbox') if platform.system() == 'Linux': sys.path.append('/usr/lib/python3/dist-packages') - spec = importlib.util.find_spec('lttoolbox') - apertium_exists = False - if spec: - apertium_exists = True - self.assertTrue(apertium_exists, 'Wrapper not installed') + self.assertIsNotNone(importlib.util.find_spec('lttoolbox'), 'Wrapper not installed') class TestTranslate(unittest.TestCase):