refactoring
This commit is contained in:
parent
babc2a6fc8
commit
41b33dad65
@ -2,7 +2,6 @@ import logging
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from image_prediction.info import Info
|
|
||||||
from image_prediction.utils import get_logger
|
from image_prediction.utils import get_logger
|
||||||
|
|
||||||
pytest_plugins = [
|
pytest_plugins = [
|
||||||
@ -26,10 +25,3 @@ def mute_logger():
|
|||||||
logger.setLevel(logging.CRITICAL + 1)
|
logger.setLevel(logging.CRITICAL + 1)
|
||||||
yield
|
yield
|
||||||
logger.setLevel(level)
|
logger.setLevel(level)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def info_label_map():
|
|
||||||
return Info
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
22
test/fixtures/metadata.py
vendored
22
test/fixtures/metadata.py
vendored
@ -8,7 +8,7 @@ from test.utils.metadata import get_base_position_metadata
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def metadata(images, info_label_map):
|
def metadata(images):
|
||||||
page_idx = 0
|
page_idx = 0
|
||||||
|
|
||||||
def current_page_idx():
|
def current_page_idx():
|
||||||
@ -25,16 +25,16 @@ def metadata(images, info_label_map):
|
|||||||
y1 = random.randint(0, page_height - height)
|
y1 = random.randint(0, page_height - height)
|
||||||
y2 = y1 + height
|
y2 = y1 + height
|
||||||
metadata = {
|
metadata = {
|
||||||
info_label_map.PAGE_WIDTH: page_width,
|
Info.PAGE_WIDTH: page_width,
|
||||||
info_label_map.PAGE_HEIGHT: page_height,
|
Info.PAGE_HEIGHT: page_height,
|
||||||
info_label_map.PAGE_IDX: current_page_idx(),
|
Info.PAGE_IDX: current_page_idx(),
|
||||||
info_label_map.WIDTH: width,
|
Info.WIDTH: width,
|
||||||
info_label_map.HEIGHT: height,
|
Info.HEIGHT: height,
|
||||||
info_label_map.X1: x1,
|
Info.X1: x1,
|
||||||
info_label_map.X2: x2,
|
Info.X2: x2,
|
||||||
info_label_map.Y1: y1,
|
Info.Y1: y1,
|
||||||
info_label_map.Y2: y2,
|
Info.Y2: y2,
|
||||||
info_label_map.ALPHA: image.mode == "RGBA",
|
Info.ALPHA: image.mode == "RGBA",
|
||||||
}
|
}
|
||||||
return metadata
|
return metadata
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ from image_prediction.compositor.compositor import TransformerCompositor
|
|||||||
from image_prediction.formatter.formatters.camel_case import Snake2CamelCaseKeyFormatter
|
from image_prediction.formatter.formatters.camel_case import Snake2CamelCaseKeyFormatter
|
||||||
from image_prediction.formatter.formatters.enum import EnumFormatter
|
from image_prediction.formatter.formatters.enum import EnumFormatter
|
||||||
from image_prediction.formatter.formatters.identity import IdentityFormatter
|
from image_prediction.formatter.formatters.identity import IdentityFormatter
|
||||||
|
from image_prediction.info import Info
|
||||||
from test.utils.comparison import transform_equal
|
from test.utils.comparison import transform_equal
|
||||||
|
|
||||||
|
|
||||||
@ -18,12 +19,12 @@ def test_composition(metadata, metadata_formatted):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def compositor_test_enum_metadata(info_label_map):
|
def compositor_test_enum_metadata():
|
||||||
return [{info_label_map.WIDTH: 100, info_label_map.PAGE_WIDTH: 200}]
|
return [{Info.WIDTH: 100, Info.PAGE_WIDTH: 200}]
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def compositor_test_camel_case_metadata(info_label_map):
|
def compositor_test_camel_case_metadata():
|
||||||
return [{"width": 100, "pageWidth": 200}]
|
return [{"width": 100, "pageWidth": 200}]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user