tests.test_labels module¶
Tests for the label rules in repomatic.labels.
A rule is one label mapped to a list of patterns: keywords or regexes over a thread’s text, globs over a pull request’s changed paths. These tests pin the resolution semantics (project entries overlay the bundled defaults per label), the pattern compiler, and the two matchers.
- tests.test_labels.test_defaults_resolve_without_a_config(resolver)[source]¶
The bundled defaults stand alone: no project config needed to match.
- tests.test_labels.test_project_entries_overlay_the_defaults(resolver, field, defaults, default_label)[source]¶
A new label adds; a default label’s entry is replaced, not merged.
- tests.test_labels.test_empty_list_disables_a_default_label()[source]¶
"🐛 bug" = []is the off switch for a bundled rule.
- tests.test_labels.test_bare_string_is_a_single_pattern()[source]¶
"🥭 mango" = "mango"reads as the one-element list it means.
- tests.test_labels.test_stale_array_of_tables_degrades_to_defaults(caplog)[source]¶
The pre-7.11.0 list shape is reported, then ignored.
The config loader passes a mistyped value through rather than crashing, so a downstream repo that has not migrated keeps every repomatic command working and falls back to the bundled defaults.
- tests.test_labels.test_unusable_entries_are_skipped_loudly(caplog, overrides, warning)[source]¶
A malformed entry is dropped with a warning, never a crash.
- tests.test_labels.test_content_pattern_forms(pattern, text, expected)[source]¶
Both the keyword and
/body/flagsspellings behave as documented.
- tests.test_labels.test_malformed_pattern_is_skipped_not_fatal(caplog)[source]¶
One bad regex must not take the whole labelling run with it.
- tests.test_labels.test_content_patterns_are_or_joined()[source]¶
Any one pattern matching applies the label: a keyword list just works.
- tests.test_labels.test_file_globs(patterns, files, expected)[source]¶
The glob dialect stays
minimatch’s, evaluated as one set per label.
- tests.test_labels.test_default_rule_labels_exist_in_the_label_registry()[source]¶
Every label the package hard-codes names one
labels.tomldefines.Applying an unknown label fails the
ghcall outright, so a rule keyed on a label the registry dropped or renamed is not a dead rule but a broken one. The sponsor-label command’s default rides the same registry and gets the same check: its label once carried a stray plural that existed in no repository, and every sponsor-labelling attempt died on it.DEPENDENCY_LABELis in the population for the same reason, being applied to every dependency-update PR.
- tests.test_labels.test_default_content_rules_match_as_advertised(text, expected)[source]¶
The shipped keyword lists fire on their keyword and nothing else.
- tests.test_labels.BUNDLED_ISSUE_FORMS = ('awesome_template/.github/ISSUE_TEMPLATE/new-link.yaml',)¶
Every issue form repomatic bundles, so a keyword in one pre-labels them all.
- tests.test_labels.test_a_bundled_issue_form_pre_labels_nothing(form_path)[source]¶
A form’s own boilerplate must not label every submission filed through it.
.githubamong the🤖 cicontent rules matched the.github/...URLs this form embeds in its self-check boxes, so all four awesome lists labelled every new-link issue as CI. Read from the bundle rather than a copied string, so a keyword a later form edit introduces fails here.
- tests.test_labels.test_default_file_rules_match_as_advertised(files, expected)[source]¶
The shipped globs cover the paths they name, and no others.
- tests.test_labels.test_label_keys_survive_config_loading()[source]¶
Emoji, spaces, colons and hyphens in label keys reach the rules intact.
The loader normalizes configuration keys (
content-rules→content_rules), and a label like📦 manager: apt-cygmust not be dragged through the same rewrite: mapping-typed fields are opaque to the normalization, which this pins.
- tests.test_labels.test_apply_labels_dry_run_on_an_issue(tmp_path)[source]¶
An issue event matches content rules only, and dry-run writes nothing.
- tests.test_labels.test_apply_labels_live_on_a_pull_request(tmp_path)[source]¶
A PR event adds the file-rule matches and writes the labels once.
- tests.test_labels.test_serialize_inline_labels_empty()[source]¶
An empty input yields an empty string so the caller can skip labelmaker.
- tests.test_labels.test_serialize_inline_labels_all_invalid_returns_empty(caplog)[source]¶
If every entry is nameless, the result is empty and warnings are logged.
- tests.test_labels.test_serialize_inline_labels_round_trip()[source]¶
Output parses back to the expected labelmaker structure.
- tests.test_labels.test_serialize_inline_labels_strips_leading_hash_on_color()[source]¶
Hex colors with a leading
#are normalized to bare hex.
- tests.test_labels.test_serialize_inline_labels_omits_missing_optional_fields()[source]¶
Missing
coloranddescriptionare omitted, not emitted as empty strings.
- tests.test_labels.test_serialize_inline_labels_passes_through_labelmaker_fields()[source]¶
Every per-label labelmaker field rides through, booleans included.
- tests.test_labels.test_serialize_inline_labels_strips_hash_on_multi_color()[source]¶
Multi-color lists are normalized to bare hex like single colors.
- tests.test_labels.test_serialize_inline_labels_omits_empty_values()[source]¶
Empty strings and empty lists are omitted, not emitted as blanks.
- tests.test_labels.test_serialize_inline_labels_warns_on_unknown_fields(caplog)[source]¶
Unknown fields are dropped with a warning instead of aborting the sync.
- tests.test_labels.test_serialize_inline_labels_skips_blank_name(caplog)[source]¶
A whitespace-only name is treated as missing.
- tests.test_labels.test_serialize_inline_labels_escapes_special_characters(name, description)[source]¶
Special characters survive serialization and re-parsing.
- tests.test_labels.captured_labelmaker(monkeypatch)[source]¶
Record every labelmaker invocation instead of running the binary.
- tests.test_labels.test_apply_labels_reads_labels_toml_from_labels_dir(tmp_path, monkeypatch, captured_labelmaker)[source]¶
labels_dirdecides wherelabels.tomlis read from, not the CWD.
- tests.test_labels.test_apply_labels_defaults_to_current_directory(tmp_path, monkeypatch, captured_labelmaker)[source]¶
Omitting
labels_dirkeeps the historical CWD-relative behaviour.
- tests.test_labels.test_apply_labels_applies_awesome_profile_from_labels_dir(tmp_path, monkeypatch, captured_labelmaker)[source]¶
The awesome profile reads the same relocated
labels.toml.