Skip to content

Commit

Permalink
validate-tags: set default for the --ignore option and add tests (#503)
Browse files Browse the repository at this point in the history
* validate-tags: set default for the --ignore option

When `--ignore` is not passed, the None default causes `Exception`s down
the line when the code tries to iterate over it.

Fixes: 015f935

* add unit tests for validate-tags-file subcommand

* tests: use sorted() for comparisons

The underlying codes relies on sets which apparently don't have
consistent sort order across Pythons.
  • Loading branch information
gotmax23 committed Apr 3, 2023
1 parent fde1e4e commit 4a140ed
Show file tree
Hide file tree
Showing 4 changed files with 661 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/antsibull/cli/antsibull_build.py
Expand Up @@ -377,7 +377,8 @@ def parse_args(program_name: str, args: list[str]) -> argparse.Namespace:
validate_tags_shared = argparse.ArgumentParser(add_help=False)
validate_tags_shared.add_argument(
'-I', '--ignore',
action='append', help='Ignore these collections when reporting errors.'
action='append', help='Ignore these collections when reporting errors.',
default=[],
)
validate_tags_shared.add_argument(
'--ignores-file',
Expand Down
15 changes: 15 additions & 0 deletions tests/conftest.py
@@ -0,0 +1,15 @@
# Copyright (C) 2023 Maxwell G <maxwell@gtmx.me>
# SPDX-License-Identifier: GPL-3.0-or-later
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or
# https://www.gnu.org/licenses/gpl-3.0.txt)

from pathlib import Path

import pytest

HERE = Path(__file__).resolve().parent
TEST_DATA = HERE / 'test_data'

@pytest.fixture
def test_data_path() -> Path:
return TEST_DATA

0 comments on commit 4a140ed

Please sign in to comment.