Skip to content

Commit

Permalink
Plural without parentheses
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Di Remigio <roberto.diremigio@gmail.com>
  • Loading branch information
robertodr committed Mar 23, 2019
1 parent d426d86 commit 77b1b5e
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 31 deletions.
2 changes: 1 addition & 1 deletion parselglossy/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def collate_errors(*, when: str, errors: List[Error]) -> str:
'user['scf']['min_num_iterations'] / 2'
"""
preamble = "\nError{more:s} occurred when {when:s}:".format(
more="(s)" if len(errors) > 1 else "", when=when
more="s" if len(errors) > 1 else "", when=when
)
msgs = [preamble] + ["{}".format(e) for e in errors]

Expand Down
14 changes: 7 additions & 7 deletions tests/test_check_predicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,43 +122,43 @@ def multiple_errors_predicates():
failing_predicates(),
pytest.raises(ParselglossyError),
[
r"Error(?:\(s\))? occurred when checking predicates:\n- At user\['scf'\]\['another_number'\]:\s+Predicate 'value % 3 == 0' not satisfied\."
r"Error(?:s)? occurred when checking predicates:\n- At user\['scf'\]\['another_number'\]:\s+Predicate 'value % 3 == 0' not satisfied\."
],
),
(
syntax_error_predicates(),
pytest.raises(ParselglossyError),
[
r"Error(?:\(s\))? occurred when checking predicates:\n- At user\['scf'\]\['another_number'\]:\s+SyntaxError.*"
r"Error(?:s)? occurred when checking predicates:\n- At user\['scf'\]\['another_number'\]:\s+SyntaxError.*"
],
),
(
name_error_predicates(),
pytest.raises(ParselglossyError),
[
r"Error(?:\(s\))? occurred when checking predicates:\n- At user\['scf'\]\['another_number'\]:\s+NameError.*"
r"Error(?:s)? occurred when checking predicates:\n- At user\['scf'\]\['another_number'\]:\s+NameError.*"
],
),
(
key_error_predicates(),
pytest.raises(ParselglossyError),
[
r"Error(?:\(s\))? occurred when checking predicates:\n- At user\['scf'\]\['another_number'\]:\s+KeyError.*"
r"Error(?:s)? occurred when checking predicates:\n- At user\['scf'\]\['another_number'\]:\s+KeyError.*"
],
),
(
type_error_predicates(),
pytest.raises(ParselglossyError),
[
r"Error(?:\(s\))? occurred when checking predicates:\n- At user\['scf'\]\['another_number'\]:\s+TypeError.*"
r"Error(?:s)? occurred when checking predicates:\n- At user\['scf'\]\['another_number'\]:\s+TypeError.*"
],
),
(
multiple_errors_predicates(),
pytest.raises(ParselglossyError),
[
r"Error(?:\(s\))? occurred when checking predicates:\n- At user\['scf'\]\['another_number'\]:\s+TypeError.*\n- At user\['title'\]:\s+KeyError.*",
r"Error(?:\(s\))? occurred when checking predicates:\n- At user\['title'\]:\s+KeyError.*\n- At user\['scf'\]\['another_number'\]:\s+TypeError.*",
r"Error(?:s)? occurred when checking predicates:\n- At user\['scf'\]\['another_number'\]:\s+TypeError.*\n- At user\['title'\]:\s+KeyError.*",
r"Error(?:s)? occurred when checking predicates:\n- At user\['title'\]:\s+KeyError.*\n- At user\['scf'\]\['another_number'\]:\s+TypeError.*",
],
),
]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_check_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
]
}

error_preamble = r"Error(?:\(s\))? occurred when checking the template:\n"
error_preamble = r"Error(?:s)? occurred when checking the template:\n"
check_template_data = [
(valid, does_not_raise()),
(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_default_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def two_invalid_actions():
return d


error_preamble = r"Error(?:\(s\))? occurred when fixing defaults:\n"
error_preamble = r"Error(?:s)? occurred when fixing defaults:\n"

msg1 = r"- At user\['scf'\]\['another_number'\]:\s+KeyError 'min_num_iterations' in closure 'user\['scf'\]\['min_num_iterations'\] / 2'\."

Expand Down
10 changes: 5 additions & 5 deletions tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,23 @@ def test_merge_expected(folder, user, template, ref):
unexpected_data = [
(
"input_missing_keyword.yml",
r"Error(?:\(s\))? occurred when merging:\n- At user\['some_section'\]\['a_short_string'\]:\s+Keyword 'a_short_string' is required but has no value\.",
r"Error(?:s)? occurred when merging:\n- At user\['some_section'\]\['a_short_string'\]:\s+Keyword 'a_short_string' is required but has no value\.",
),
(
"unexpected_keyword.yml",
r"Error(?:\(s\))? occurred when merging:\n- Found unexpected keyword: 'strange'",
r"Error(?:s)? occurred when merging:\n- Found unexpected keyword: 'strange'",
),
(
"unexpected_section.yml",
r"Error(?:\(s\))? occurred when merging:\n- Found unexpected section: 'weird'",
r"Error(?:s)? occurred when merging:\n- Found unexpected section: 'weird'",
),
(
"unexpected_keyword_in_section.yml",
r"Error(?:\(s\))? occurred when merging:\n- Found unexpected keyword: 'strange'",
r"Error(?:s)? occurred when merging:\n- Found unexpected keyword: 'strange'",
),
(
"unexpected_section_nested.yml",
r"Error(?:\(s\))? occurred when merging:\n- Found unexpected section: 'weird'",
r"Error(?:s)? occurred when merging:\n- Found unexpected section: 'weird'",
),
]

Expand Down
2 changes: 1 addition & 1 deletion tests/test_type_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def type_error_str():
}
n = "type_error_str"
e = r"""
Error(?:\(s\))? occurred when fixing defaults:
Error(?:s)? occurred when fixing defaults:
- At user\['some_section'\]\['a_short_string'\]:
Actual \(int\) and declared \(str\) types do not match\."""

Expand Down
26 changes: 11 additions & 15 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,15 @@ def valid():
"unexpected_keyword.yml",
"template.yml",
pytest.raises(ParselglossyError),
[
r"Error(?:\(s\))? occurred when merging:\n- Found unexpected keyword: 'strange'"
],
[r"Error(?:s)? occurred when merging:\n- Found unexpected keyword: 'strange'"],
None,
),
(
"input_errors",
"unexpected_section.yml",
"template.yml",
pytest.raises(ParselglossyError),
[
r"Error(?:\(s\))? occurred when merging:\n- Found unexpected section: 'weird'"
],
[r"Error(?:s)? occurred when merging:\n- Found unexpected section: 'weird'"],
None,
),
(
Expand All @@ -115,7 +111,7 @@ def valid():
"template.yml",
pytest.raises(ParselglossyError),
[
r"Error(?:\(s\))? occurred when merging:\n- At user\['some_section'\]\['a_short_string'\]:\s+Keyword 'a_short_string' is required but has no value\."
r"Error(?:s)? occurred when merging:\n- At user\['some_section'\]\['a_short_string'\]:\s+Keyword 'a_short_string' is required but has no value\."
],
None,
),
Expand All @@ -125,7 +121,7 @@ def valid():
"template.yml",
pytest.raises(ParselglossyError),
[
r"Error(?:\(s\))? occurred when fixing defaults:\n- At user\['some_section'\]\['some_feature'\]:\s+Actual \(int\) and declared \(bool\) types do not match\."
r"Error(?:s)? occurred when fixing defaults:\n- At user\['some_section'\]\['some_feature'\]:\s+Actual \(int\) and declared \(bool\) types do not match\."
],
None,
),
Expand All @@ -135,7 +131,7 @@ def valid():
"template.yml",
pytest.raises(ParselglossyError),
[
r"Error(?:\(s\))? occurred when fixing defaults:\n- At user\['some_float'\]:\s+Actual \(int\) and declared \(float\) types do not match\."
r"Error(?:s)? occurred when fixing defaults:\n- At user\['some_float'\]:\s+Actual \(int\) and declared \(float\) types do not match\."
],
None,
),
Expand All @@ -145,7 +141,7 @@ def valid():
"template.yml",
pytest.raises(ParselglossyError),
[
r"Error(?:\(s\))? occurred when fixing defaults:\n- At user\['some_section'\]\['some_number'\]:\s+Actual \(float\) and declared \(int\) types do not match\."
r"Error(?:s)? occurred when fixing defaults:\n- At user\['some_section'\]\['some_number'\]:\s+Actual \(float\) and declared \(int\) types do not match\."
],
None,
),
Expand All @@ -155,7 +151,7 @@ def valid():
"template.yml",
pytest.raises(ParselglossyError),
[
r"Error(?:\(s\))? occurred when fixing defaults:\n- At user\['some_section'\]\['some_list'\]:\s+Actual \(List\[float, float, int\]\) and declared \(List\[float\]\) types do not match\."
r"Error(?:s)? occurred when fixing defaults:\n- At user\['some_section'\]\['some_list'\]:\s+Actual \(List\[float, float, int\]\) and declared \(List\[float\]\) types do not match\."
],
None,
),
Expand All @@ -165,7 +161,7 @@ def valid():
"template.yml",
pytest.raises(ParselglossyError),
[
r"Error(?:\(s\))? occurred when fixing defaults:\n- At user\['some_section'\]\['a_short_string'\]:\s+Actual \(int\) and declared \(str\) types do not match\."
r"Error(?:s)? occurred when fixing defaults:\n- At user\['some_section'\]\['a_short_string'\]:\s+Actual \(int\) and declared \(str\) types do not match\."
],
None,
),
Expand All @@ -175,7 +171,7 @@ def valid():
"template.yml",
pytest.raises(ParselglossyError),
[
r"Error(?:\(s\))? occurred when checking predicates:\n- At user\['some_section'\]\['another_number'\]:\s+Predicate 'value % 2 == 0' not satisfied\."
r"Error(?:s)? occurred when checking predicates:\n- At user\['some_section'\]\['another_number'\]:\s+Predicate 'value % 2 == 0' not satisfied\."
],
None,
),
Expand All @@ -185,10 +181,10 @@ def valid():
"template.yml",
pytest.raises(ParselglossyError),
[
r"Error(?:\(s\))? occurred when checking predicates:"
r"Error(?:s)? occurred when checking predicates:"
r"\n- At user\['some_section'\]\['some_number'\]:\s+Predicate 'value < user\['some_section'\]\['another_number'\]' not satisfied\."
r"\n- At user\['some_section'\]\['another_number'\]:\s+Predicate 'value > user\['some_section'\]\['some_number'\]' not satisfied\.",
r"Error(?:\(s\))? occurred when checking predicates:"
r"Error(?:s)? occurred when checking predicates:"
r"\n- At user\['some_section'\]\['another_number'\]:\s+Predicate 'value > user\['some_section'\]\['some_number'\]' not satisfied\."
r"\n- At user\['some_section'\]\['some_number'\]:\s+Predicate 'value < user\['some_section'\]\['another_number'\]' not satisfied\.",
],
Expand Down

0 comments on commit 77b1b5e

Please sign in to comment.