How to use _run_test_case method in Testify

Best Python code snippet using Testify_python

test_glossaries.py

Source:test_glossaries.py Github

copy

Full Screen

...10from apply_bpe import isolate_glossary, BPE11class TestIsolateGlossaryFunction(unittest.TestCase):12 def setUp(self):13 self.glossary = 'like'14 def _run_test_case(self, test_case):15 orig, expected = test_case16 out = isolate_glossary(orig, self.glossary)17 self.assertEqual(out, expected)18 def test_empty_string(self):19 orig = ''20 exp = ['']21 test_case = (orig, exp)22 self._run_test_case(test_case)23 def test_no_glossary(self):24 orig = 'word'25 exp = ['word']26 test_case = (orig, exp)27 self._run_test_case(test_case)28 def test_isolated_glossary(self):29 orig = 'like'30 exp = ['like']31 test_case = (orig, exp)32 self._run_test_case(test_case)33 def test_word_one_side(self):34 orig = 'likeword'35 exp = ['like', 'word']36 test_case = (orig, exp)37 self._run_test_case(test_case)38 def test_words_both_sides(self):39 orig = 'wordlikeword'40 exp = ['word', 'like', 'word']41 test_case = (orig, exp)42 self._run_test_case(test_case)43 def test_back_to_back_glossary(self):44 orig = 'likelike'45 exp = ['like', 'like']46 test_case = (orig, exp)47 self._run_test_case(test_case)48 def test_multiple_glossaries(self):49 orig = 'wordlikewordlike'50 exp = ['word', 'like', 'word', 'like']51 test_case = (orig, exp)52 self._run_test_case(test_case)53class TestBPEIsolateGlossariesMethod(unittest.TestCase):54 def setUp(self):55 56 amock = mock.MagicMock()57 amock.readline.return_value = 'something'58 glossaries = ['like', 'Manuel', 'USA']59 self.bpe = BPE(amock, glossaries=glossaries)60 def _run_test_case(self, test_case):61 orig, expected = test_case62 out = self.bpe._isolate_glossaries(orig)63 self.assertEqual(out, expected)64 def test_multiple_glossaries(self):65 orig = 'wordlikeUSAwordManuelManuelwordUSA'66 exp = ['word', 'like', 'USA', 'word', 'Manuel', 'Manuel', 'word', 'USA']67 test_case = (orig, exp)68 self._run_test_case(test_case)69def encode_mock(segment, x2, x3, x4, x5, x6, glosses):70 if segment in glosses:71 return (segment,)72 else:73 l = len(segment)74 return (segment[:l/2], segment[l/2:])75class TestBPESegmentMethod(unittest.TestCase):76 def setUp(self):77 78 amock = mock.MagicMock()79 amock.readline.return_value = 'something'80 glossaries = ['like', 'Manuel', 'USA']81 self.bpe = BPE(amock, glossaries=glossaries)82 @mock.patch('apply_bpe.encode', side_effect=encode_mock)83 def _run_test_case(self, test_case, encode_function):84 orig, expected = test_case85 out = self.bpe.segment(orig)86 self.assertEqual(out, expected)87 def test_multiple_glossaries(self):88 orig = 'wordlikeword likeManuelword'89 exp = 'wo@@ rd@@ like@@ wo@@ rd like@@ Manuel@@ wo@@ rd'90 test_case = (orig, exp)91 self._run_test_case(test_case)92if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testify automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful