Skip to content

Commit 4d64aa7

Browse files
authored
Remove Pillow dependency from tests (#27)
1 parent 29077ca commit 4d64aa7

File tree

4 files changed

+17
-33
lines changed

4 files changed

+17
-33
lines changed

test-requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
pytest==2.9.1
22
responses==0.5.1
33
mock>=2.0
4-
Pillow==6.2.0
54
flake8
6-

tests/test_util.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,16 @@ def function_that_takes_theme_params(logo=None, color=''):
115115

116116

117117
def test_process_theme_params_right_path():
118-
with get_temporary_logo() as path_to_logo:
119-
with open(path_to_logo, 'rb') as logo:
120-
encoded_logo = base64.b64encode(logo.read())
118+
path_to_logo = get_temporary_logo()
119+
with open(path_to_logo, 'rb') as logo:
120+
encoded_logo = base64.b64encode(logo.read())
121121

122-
@process_theme_params
123-
def function_that_takes_theme_params(logo=None, color=''):
124-
assert logo == encoded_logo
125-
assert color == '#eeff00'
122+
@process_theme_params
123+
def function_that_takes_theme_params(logo=None, color=''):
124+
assert logo == encoded_logo
125+
assert color == '#eeff00'
126126

127-
function_that_takes_theme_params(logo=path_to_logo, color='eeff00')
127+
function_that_takes_theme_params(logo=path_to_logo, color='eeff00')
128128

129129

130130
def test_process_theme_params_logo_from_txt():
@@ -142,14 +142,14 @@ def test_process_theme_params_logo_from_url():
142142
responses.add(responses.HEAD,
143143
'http://somehost.no/rand_logo.png',
144144
status=200)
145-
with get_temporary_logo() as path:
146-
with open(path, 'rb') as logo:
147-
responses.add(responses.GET,
148-
'http://somehost.no/rand_logo.png',
149-
content_type='image/png',
150-
stream=True,
151-
body=logo.read(),
152-
status=200)
145+
path = get_temporary_logo()
146+
with open(path, 'rb') as logo:
147+
responses.add(responses.GET,
148+
'http://somehost.no/rand_logo.png',
149+
content_type='image/png',
150+
stream=True,
151+
body=logo.read(),
152+
status=200)
153153

154154
@process_theme_params
155155
def function_that_takes_theme_params(logo=None, color=''):

tests/util/logo.jpg

1.38 KB
Loading

tests/util/temp_files.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
import os
2-
32
from contextlib import contextmanager
4-
from random import randint
5-
from PIL import Image
63

74
from tests.util.params import LOGO_BASE64
85

96

10-
@contextmanager
117
def get_temporary_logo():
12-
path_to_logo = os.path.join(os.path.abspath('.'),
13-
'tests/util/temp_logo.png')
14-
try:
15-
image = Image.new("RGBA", (16, 16), (randint(1, 100),
16-
randint(1, 100),
17-
randint(1, 100),
18-
randint(1, 100)))
19-
image.save(path_to_logo)
20-
yield path_to_logo
21-
finally:
22-
os.remove(path_to_logo)
8+
return os.path.join(os.path.dirname(__file__), 'logo.jpg')
239

2410

2511
@contextmanager

0 commit comments

Comments
 (0)