forked from dal-lab/git-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext_formatter_test.py
More file actions
51 lines (37 loc) · 1.39 KB
/
text_formatter_test.py
File metadata and controls
51 lines (37 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
string_maker test
"""
import pytest
import text_formatter
def test_string_maker_length():
length = 10
text_length_10 = text_formatter.string_maker(length=length)
assert len(text_length_10('12345')) == length
def test_string_maker_length_over():
length = 10
text_length_10 = text_formatter.string_maker(length=length)
assert len(text_length_10('1234567890123')) == length
def test_string_maker_align_left():
test_word = 'AAAAA'
length = 20
text_align_left = text_formatter.string_maker(length=length)
assert text_align_left(test_word) == test_word.ljust(length, ' ')
def test_string_maker_align_right():
test_word = 'AAAAA'
length = 20
text_align_right = text_formatter.string_maker(
length=length, align='RIGHT')
assert text_align_right(test_word) == test_word.rjust(length, ' ')
def test_string_maker_align_center():
test_word = 'AAAAA'
length = 20
text_align_center = text_formatter.string_maker(length=length, align='MID')
assert text_align_center(test_word) == test_word.center(length, ' ')
def test_string_maker_align_center_padding_star():
test_word = 'AAAAA'
length = 20
padding = '*'
text_align_center_padding_star = text_formatter.string_maker(
length=length, align='MID', padding=padding)
assert text_align_center_padding_star(test_word) \
== test_word.center(length, padding)