Fix package structure and lazy-import ODT formatter
Add missing __init__.py to formatters/ so setuptools.find_packages includes the subpackage in wheel/sdist builds (#16). Move ODTFormatter import from top-level to lazy import inside get_formatter_by_extension() so missing odfpy no longer crashes module load before main() runs. Remove dead except ImportError handler in cli.py save() block; surface a clear 'odfpy is not installed' message when the formatter factory returns None for .odt (#25). Closes #16, closes #25
This commit is contained in:
@@ -94,3 +94,17 @@ def test_cli_output_without_extension(mock_fetch, tmp_path):
|
||||
output = str(tmp_path / "report")
|
||||
code = main(["--date", "2026-01-01--2026-01-31", "--output", output])
|
||||
assert code == 1
|
||||
|
||||
|
||||
@mock.patch.dict(os.environ, VALID_ENV, clear=True)
|
||||
@mock.patch("redmine_reporter.cli.fetch_issues_with_spent_time")
|
||||
@mock.patch("redmine_reporter.cli.get_formatter_by_extension")
|
||||
def test_cli_odt_missing_odfpy_message(mock_gf, mock_fetch, tmp_path, capsys):
|
||||
"""При запросе .odt без odfpy — выход 1, понятное сообщение про odfpy."""
|
||||
mock_fetch.return_value = []
|
||||
mock_gf.return_value = None
|
||||
output = str(tmp_path / "report.odt")
|
||||
code = main(["--date", "2026-01-01--2026-01-31", "--output", output])
|
||||
assert code == 1
|
||||
captured = capsys.readouterr()
|
||||
assert "odfpy" in captured.err
|
||||
|
||||
Reference in New Issue
Block a user