refactoring: splitting conftest logic into submodules
This commit is contained in:
parent
4fa1ab83b8
commit
d39075e85e
@ -1,15 +1,10 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
|
|
||||||
import fpdf
|
|
||||||
import numpy as np
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from image_prediction.info import Info
|
from image_prediction.info import Info
|
||||||
from image_prediction.locations import TEST_DATA_DIR
|
|
||||||
from image_prediction.pipeline import load_pipeline
|
from image_prediction.pipeline import load_pipeline
|
||||||
from image_prediction.utils import get_logger
|
from image_prediction.utils import get_logger
|
||||||
from test.utils.generation.pdf import add_image, pdf_stream
|
|
||||||
|
|
||||||
pytest_plugins = [
|
pytest_plugins = [
|
||||||
"test.fixtures.image",
|
"test.fixtures.image",
|
||||||
@ -34,32 +29,11 @@ def mute_logger():
|
|||||||
logger.setLevel(level)
|
logger.setLevel(level)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def input_batch(batch_size, input_size):
|
|
||||||
return np.random.random_sample(size=(batch_size, *input_size))
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def info_label_map():
|
def info_label_map():
|
||||||
return Info
|
return Info
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def pdf(image_metadata_pairs):
|
|
||||||
pdf = fpdf.FPDF(unit="pt")
|
|
||||||
|
|
||||||
for pair in image_metadata_pairs:
|
|
||||||
add_image(pdf, pair)
|
|
||||||
|
|
||||||
return pdf_stream(pdf)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def real_pdf():
|
|
||||||
with open(os.path.join(TEST_DATA_DIR, "f2dc689ca794fccb8cd38b95f2bf6ba9.pdf"), "rb") as f:
|
|
||||||
yield f.read()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def pipeline():
|
def pipeline():
|
||||||
pipeline = load_pipeline(verbose=False)
|
pipeline = load_pipeline(verbose=False)
|
||||||
|
|||||||
7
test/fixtures/input.py
vendored
7
test/fixtures/input.py
vendored
@ -0,0 +1,7 @@
|
|||||||
|
import numpy as np
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def input_batch(batch_size, input_size):
|
||||||
|
return np.random.random_sample(size=(batch_size, *input_size))
|
||||||
23
test/fixtures/pdf.py
vendored
23
test/fixtures/pdf.py
vendored
@ -0,0 +1,23 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import fpdf
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from image_prediction.locations import TEST_DATA_DIR
|
||||||
|
from test.utils.generation.pdf import add_image, pdf_stream
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def pdf(image_metadata_pairs):
|
||||||
|
pdf = fpdf.FPDF(unit="pt")
|
||||||
|
|
||||||
|
for pair in image_metadata_pairs:
|
||||||
|
add_image(pdf, pair)
|
||||||
|
|
||||||
|
return pdf_stream(pdf)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def real_pdf():
|
||||||
|
with open(os.path.join(TEST_DATA_DIR, "f2dc689ca794fccb8cd38b95f2bf6ba9.pdf"), "rb") as f:
|
||||||
|
yield f.read()
|
||||||
Loading…
x
Reference in New Issue
Block a user