Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests #381

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions marker/config/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from marker.renderers.html import HTMLRenderer
from marker.settings import settings
from marker.util import parse_range_str, strings_to_classes, classes_to_string
from marker.util import parse_range_str, strings_to_classes, classes_to_strings
from marker.renderers.markdown import MarkdownRenderer
from marker.renderers.json import JSONRenderer

Expand Down Expand Up @@ -69,7 +69,7 @@ def get_renderer(self):
r = HTMLRenderer
case _:
raise ValueError("Invalid output format")
return classes_to_string([r])[0]
return classes_to_strings([r])[0]

def get_processors(self):
processors = self.cli_options.get("processors", None)
Expand Down
2 changes: 1 addition & 1 deletion marker/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def strings_to_classes(items: List[str]) -> List[type]:
return classes


def classes_to_string(items: List[type]) -> List[str]:
def classes_to_strings(items: List[type]) -> List[str]:
for item in items:
if not inspect.isclass(item):
raise ValueError(f"Item {item} is not a class")
Expand Down
19 changes: 7 additions & 12 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from marker.renderers.markdown import MarkdownRenderer
from marker.renderers.json import JSONRenderer
from marker.schema.registry import register_block_class
from marker.util import classes_to_strings


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -120,9 +121,9 @@ def pdf_converter(request, config, layout_model, texify_model, recognition_model
DebugProcessor,
]
yield PdfConverter(
model_dict=model_dict,
processor_list=processor_list,
renderer=renderer,
artifact_dict=model_dict,
processor_list=classes_to_strings(processor_list),
renderer=classes_to_strings([renderer])[0],
config=config
)

Expand All @@ -132,16 +133,10 @@ def renderer(request, config):
if request.node.get_closest_marker("output_format"):
output_format = request.node.get_closest_marker("output_format").args[0]
if output_format == "markdown":
return MarkdownRenderer(config)
return MarkdownRenderer
elif output_format == "json":
return JSONRenderer(config)
return JSONRenderer
else:
raise ValueError(f"Unknown output format: {output_format}")
else:
return MarkdownRenderer(config)


@pytest.fixture(scope="function")
@pytest.mark.output_format("markdown")
def markdown_output(request, temp_pdf, pdf_converter, renderer):
yield pdf_converter(temp_pdf.name)
return MarkdownRenderer