-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac8b593
commit 727a475
Showing
3 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import sys | ||
from contextlib import suppress | ||
from marker.config.parser import ConfigParser | ||
|
||
import click | ||
|
||
from marker.config.printer import CustomClickPrinter | ||
|
||
|
||
def test_config_parser(): | ||
command = click.command(cls=CustomClickPrinter) | ||
captured_kwargs = {} | ||
|
||
def parse_args(**kwargs): | ||
captured_kwargs.update(kwargs) | ||
return kwargs | ||
|
||
original_argv = sys.argv | ||
sys.argv = ['test', '--disable_multiprocessing', '--output_dir', 'output_dir', "--height_tolerance", "0.5"] | ||
try: | ||
with suppress(SystemExit): | ||
command(ConfigParser.common_options(parse_args))() | ||
finally: | ||
sys.argv = original_argv | ||
|
||
kwargs = captured_kwargs | ||
parser = ConfigParser(kwargs) | ||
config_dict = parser.generate_config_dict() | ||
|
||
# Validate kwarg capturing | ||
assert captured_kwargs["disable_multiprocessing"] == True | ||
assert captured_kwargs["output_dir"] == "output_dir" | ||
|
||
assert config_dict["pdftext_workers"] == 1 # disabling multiprocessing does this | ||
assert config_dict["height_tolerance"] == 0.5 | ||
assert "output_dir" not in config_dict # This is not a config key |