Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VikParuchuri committed Nov 21, 2024
1 parent 7d3de8c commit ec0fe7e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
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

0 comments on commit ec0fe7e

Please sign in to comment.