-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_gen_ascii.py
50 lines (43 loc) · 1.2 KB
/
test_gen_ascii.py
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
import platform
from PIL import Image
import constants
import gen_ascii
CHARS = gen_ascii.get_char_set(
constants.CHAR_DARKNESS_TEXT_ONLY, constants.MAX_VAL
)
more = gen_ascii.get_char_set(
constants.CHAR_DARKNESS_NON_TEXT, constants.MAX_VAL
)
i = 0
for smaller_list in CHARS:
for character in more[i]:
if character not in smaller_list:
CHARS[i].append(character)
i += 1
SCALE = gen_ascii.calc_scale(constants.MIN_VAL, constants.MAX_VAL)
assert gen_ascii.generate_char(0, "r", CHARS) == " "
assert gen_ascii.generate_char(21, "r", CHARS) in (
"a",
"n",
"s",
"y",
"z",
"*",
)
assert gen_ascii.generate_char(21, "l", CHARS) == "a"
assert gen_ascii.generate_char(3, "r", CHARS) in ("'", ".")
assert gen_ascii.generate_char(32, "l", CHARS) == "H"
assert gen_ascii.generate_char(34, "l", CHARS) == "@"
my_os = platform.system()
if my_os == "Windows":
img = Image.open("images\python.jpg")
img2 = Image.open("images\python.png")
else:
img = Image.open("images/python.jpg")
img2 = Image.open("images/python.png")
gen_ascii.create_ascii(
img, CHARS, "l", 4, SCALE
)
gen_ascii.create_ascii(
img2, CHARS, "l", 3, SCALE
)