def test_generate_data_with_extension(self): FakeTextDataGenerator.generate( 1, 'TEST TEST TEST', 'tests/font.ttf', 'tests/out/', 32, 'png', 0, False, 0, False, 1, 0, 0, False, 0, -1, 0, '#010101', 0, 1, (5,5,5,5), 0 ) self.assertTrue( md5('tests/out/TEST TEST TEST_1.png') == md5('tests/expected_results/TEST TEST TEST_1.png') ) os.remove('tests/out/TEST TEST TEST_1.png')
def test_generate_text_with_unknown_orientation(self): try: FakeTextDataGenerator.generate( 12, 'TEST TEST TEST', 'tests/font.ttf', 'tests/out/', 32, 'jpg', 0, False, 0, False, 1, 0, 0, False, 0, -1, 0, '#010101', 100, 2, (5,5,5,5), 0 ) raise Exception("Unknown orientation did not throw") except ValueError: pass
def test_generate_data_with_format(self): FakeTextDataGenerator.generate( 0, 'TEST TEST TEST', 'tests/font.ttf', 'tests/out/', 64, 'jpg', 0, False, 0, False, 1, 0, 0, False, 0, -1, 0, '#010101', 0, 1, (5,5,5,5), 0 ) self.assertTrue( md5('tests/out/TEST TEST TEST_0.jpg') == md5('tests/expected_results/TEST TEST TEST_0.jpg') ) os.remove('tests/out/TEST TEST TEST_0.jpg')
def test_raise_if_handwritten_and_vertical(self): try: FakeTextDataGenerator.generate( 9, 'TEST TEST TEST', 'tests/font.ttf', 'tests/out/', 64, 'jpg', 0, False, 0, False, 1, 0, 0, True, 0, 1000, 2, '#010101', 1, 1, (5,5,5,5), 0 ) raise Exception("Vertical handwritten did not throw") except ValueError: pass
def test_generate_vertical_text_with_variable_space(self): FakeTextDataGenerator.generate( 12, 'TEST TEST TEST', 'tests/font.ttf', 'tests/out/', 32, 'jpg', 0, False, 0, False, 1, 0, 0, False, 0, -1, 0, '#010101', 1, 2, (5,5,5,5), 0 ) self.assertTrue( md5('tests/out/TEST TEST TEST_12.jpg') == md5('tests/expected_results/TEST TEST TEST_12.jpg') ) os.remove('tests/out/TEST TEST TEST_12.jpg')
def test_generate_data_with_center_alignment(self): FakeTextDataGenerator.generate( 7, 'TEST TEST TEST', 'tests/font.ttf', 'tests/out/', 64, 'jpg', 0, False, 0, False, 1, 0, 0, False, 0, 800, 1, '#010101' ) self.assertTrue( md5('tests/out/TEST TEST TEST_7.jpg') == md5('tests/expected_results/TEST TEST TEST_7.jpg') ) os.remove('tests/out/TEST TEST TEST_7.jpg')
def test_generate_data_with_right_alignment(self): FakeTextDataGenerator.generate( 8, 'TEST TEST TEST', 'tests/font.ttf', 'tests/out/', 64, 'jpg', 0, False, 0, False, 1, 0, 0, False, 0, 1000, 2, '#010101', 0, 1, (5,5,5,5), 0 ) self.assertTrue( md5('tests/out/TEST TEST TEST_8.jpg') == md5('tests/expected_results/TEST TEST TEST_8.jpg') ) os.remove('tests/out/TEST TEST TEST_8.jpg')
def test_generate_data_with_cosine_distorsion(self): FakeTextDataGenerator.generate( 5, 'TEST TEST TEST', 'tests/font.ttf', 'tests/out/', 64, 'jpg', 0, False, 3, False, 1, 2, 2, False, 0, -1, 0, '#010101' ) self.assertTrue( md5('tests/out/TEST TEST TEST_5.jpg') == md5('tests/expected_results/TEST TEST TEST_5.jpg') ) os.remove('tests/out/TEST TEST TEST_5.jpg')
def test_generate_data_with_skew_angle(self): FakeTextDataGenerator.generate( 2, 'TEST TEST TEST', 'tests/font.ttf', 'tests/out/', 64, 'jpg', 15, False, 0, False, 1, 0, 0, False, 0, -1, 0, '#010101' ) self.assertTrue( md5('tests/out/TEST TEST TEST_2.jpg') == md5('tests/expected_results/TEST TEST TEST_2.jpg') ) os.remove('tests/out/TEST TEST TEST_2.jpg')
def test_generate_data_with_blur(self): FakeTextDataGenerator.generate( 3, 'TEST TEST TEST', 'tests/font.ttf', 'tests/out/', 64, 'jpg', 0, False, 3, False, 1, 0, 0, False, 0, 1 ) self.assertTrue( md5('tests/out/TEST TEST TEST_3.jpg') == md5('tests/expected_results/TEST TEST TEST_3.jpg') ) os.remove('tests/out/TEST TEST TEST_3.jpg')
def test_generate_vertical_text(self): FakeTextDataGenerator.generate( 10, 'TEST TEST TEST', 'tests/font.ttf', 'tests/out/', 32, 'jpg', 0, False, 0, False, 1, 0, 0, False, 0, -1, 0, '#010101', 1, 1 ) self.assertTrue( md5('tests/out/TEST TEST TEST_10.jpg') == md5('tests/expected_results/TEST TEST TEST_10.jpg') ) os.remove('tests/out/TEST TEST TEST_10.jpg')
def test_generate_data_with_left_alignment(self): FakeTextDataGenerator.generate(6, 'TEST TEST TEST', 'tests/font.ttf', 'tests/out/', 64, 'jpg', 0, False, 0, False, 1, 0, 0, False, 0, 600, 0, (1, 1)) self.assertTrue( md5('tests/out/TEST TEST TEST_6.jpg') == md5( 'tests/expected_results/TEST TEST TEST_6.jpg')) os.remove('tests/out/TEST TEST TEST_6.jpg')