Skip to content

Commit

Permalink
tests: cover empty args in exception
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestoarbitrio committed Sep 22, 2020
1 parent 80a984f commit 5d33ea9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
7 changes: 7 additions & 0 deletions tests/unit/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ def it_knows_its_message_from_none_level_error(self):

assert message is None

def it_knows_its_message_from_empty_level_error(self):
level_error = exp.LevelError()

message = level_error.message

assert message is None

def it_knows_its_str_from_str_level_error(self):
arg = "error"
level_error = exp.LevelError(arg)
Expand Down
14 changes: 6 additions & 8 deletions tests/unitutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys

import numpy as np
import PIL
from PIL import Image

from unittest.mock import ANY, call # noqa # isort:skip
from unittest.mock import create_autospec, patch, PropertyMock # isort:skip
Expand Down Expand Up @@ -94,22 +94,20 @@ def is_win32():


class PILImageMock:
RGBA_COLOR_500X500_155_249_240 = PIL.Image.new(
RGBA_COLOR_500X500_155_249_240 = Image.new(
"RGBA", size=(500, 500), color=(155, 249, 240)
)
RGBA_COLOR_50X50_155_0_0 = PIL.Image.new("RGBA", size=(50, 50), color=(155, 0, 0))
RGBA_COLOR_50X50_155_0_0 = Image.new("RGBA", size=(50, 50), color=(155, 0, 0))

RGB_RANDOM_COLOR_500X500 = PIL.Image.fromarray(
RGB_RANDOM_COLOR_500X500 = Image.fromarray(
(np.random.rand(500, 500, 3) * 255).astype("uint8")
).convert("RGB")

RGB_RANDOM_COLOR_10X10 = PIL.Image.fromarray(
RGB_RANDOM_COLOR_10X10 = Image.fromarray(
(np.random.rand(10, 10, 3) * 255).astype("uint8")
).convert("RGB")

GRAY_RANDOM_10X10 = PIL.Image.fromarray(
(np.random.rand(10, 10) * 255).astype("uint8")
)
GRAY_RANDOM_10X10 = Image.fromarray((np.random.rand(10, 10) * 255).astype("uint8"))


class NpArrayMock:
Expand Down

0 comments on commit 5d33ea9

Please sign in to comment.