Skip to content

Commit

Permalink
run __main__ in test
Browse files Browse the repository at this point in the history
  • Loading branch information
tetov committed Nov 4, 2024
1 parent 0d3d9cb commit 553b8d8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/bdm_voxel_builder/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,7 @@ def _load_config(config_file: pathlib.Path) -> Config:

return config_module.config


@click.command()
@click.argument(
"config-file", type=click.Path(exists=True), default=DATA_DIR / "config.py"
)
def main(config_file):
config: Config = _load_config(config_file)

def run_algo(config: Config):
algo = config.algo
visualizer = config.visualizer
iterations = config.iterations
Expand Down Expand Up @@ -92,5 +85,13 @@ def main(config_file):
visualizer.show()


@click.command()
@click.argument(
"config-file", type=click.Path(exists=True), default=DATA_DIR / "config.py"
)
def main(config_file):
config: Config = _load_config(config_file)
run_algo(config)

if __name__ == "__main__":
main()
12 changes: 12 additions & 0 deletions tests/test_run_with_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from bdm_voxel_builder import DATA_DIR
from bdm_voxel_builder.__main__ import _load_config, run_algo
from bdm_voxel_builder.config_setup import Config


def test_run_with_config():
config: Config = _load_config(DATA_DIR / "config.py")
config.iterations = 10
config.visualizer = None

run_algo(config)

0 comments on commit 553b8d8

Please sign in to comment.