mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-06 04:56:54 +00:00
Refactor decision logic into its own object
In dealing with the decision logic in the StyleGuide recently I recognized that the logic really doesn't belong strictly on the StyleGuide. A separate object makes perfect sense especially from the perspective of testability. This is a minor refactor intended solely to facilitate further testing and perhaps making the logic easier to understand for others.
This commit is contained in:
parent
feec0754bd
commit
7fef0af0f5
2 changed files with 112 additions and 56 deletions
|
|
@ -183,22 +183,16 @@ def test_should_report_error(select_list, ignore_list, error_code, expected):
|
|||
)
|
||||
def test_decision_for_logic(select, ignore, extend_select, enabled_extensions,
|
||||
error_code, expected):
|
||||
"""Verify the complicated logic of StyleGuide._decision_for.
|
||||
|
||||
I usually avoid testing private methods, but this one is very important in
|
||||
our conflict resolution work in Flake8.
|
||||
"""
|
||||
guide = style_guide.StyleGuide(
|
||||
"""Verify the complicated logic of DecisionEngine.decision_for."""
|
||||
decider = style_guide.DecisionEngine(
|
||||
create_options(
|
||||
select=select, ignore=ignore,
|
||||
extended_default_select=extend_select,
|
||||
enable_extensions=enabled_extensions,
|
||||
),
|
||||
listener_trie=None,
|
||||
formatter=None,
|
||||
)
|
||||
|
||||
assert guide._decision_for(error_code) is expected
|
||||
assert decider.decision_for(error_code) is expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize('error_code,physical_line,expected_result', [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue