Skip to content

Commit f47b69e

Browse files
committed
Add test for edge case
1 parent ccfd8bf commit f47b69e

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

TextRecognitionDataGenerator/computer_text_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def generate(cls, text, font, text_color, font_size, orientation, space_width):
1010
elif orientation == 1:
1111
return cls.__generate_vertical_text(text, font, text_color, font_size, space_width)
1212
else:
13-
raise Exception("Unknown orientation " + str(orientation))
13+
raise ValueError("Unknown orientation " + str(orientation))
1414

1515
@classmethod
1616
def __generate_horizontal_text(cls, text, font, text_color, font_size, space_width):

tests.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,34 @@ def test_generate_vertical_text_with_variable_space(self):
453453

454454
os.remove('tests/out/TEST TEST TEST_12.jpg')
455455

456+
def test_generate_text_with_unknown_orientation(self):
457+
try:
458+
FakeTextDataGenerator.generate(
459+
12,
460+
'TEST TEST TEST',
461+
'tests/font.ttf',
462+
'tests/out/',
463+
32,
464+
'jpg',
465+
0,
466+
False,
467+
0,
468+
False,
469+
1,
470+
0,
471+
0,
472+
False,
473+
0,
474+
-1,
475+
0,
476+
'#010101',
477+
100,
478+
2
479+
)
480+
raise Exception("Unknown orientation did not throw")
481+
except ValueError:
482+
pass
483+
456484
def test_generate_string_with_letters(self):
457485
s = create_strings_randomly(1, False, 1, True, False, False, 'en')[0]
458486

0 commit comments

Comments
 (0)