|
18 | 18 | from usethis._tool.pre_commit import PreCommitConfig, PreCommitRepoConfig |
19 | 19 | from usethis._tool.rule import Rule, RuleConfig |
20 | 20 | from usethis._types.deps import Dependency |
| 21 | +from usethis.errors import UnhandledConfigEntryError |
21 | 22 |
|
22 | 23 |
|
23 | 24 | class DefaultTool(Tool): |
@@ -1402,24 +1403,21 @@ def test_it_returns_false(self) -> None: |
1402 | 1403 | assert result is False |
1403 | 1404 | file_manager.extend_list.assert_not_called() |
1404 | 1405 |
|
1405 | | - class TestToolWithoutSelectionSupport: |
1406 | | - def test_it_raises_not_implemented_error(self) -> None: |
1407 | | - # Arrange |
1408 | | - file_manager = MagicMock() |
1409 | | - tool = MockToolForRuleTests( |
1410 | | - file_manager=file_manager, selected_rules=[] |
1411 | | - ) |
1412 | | - # Override to simulate a tool without selection support |
1413 | | - tool._get_select_keys = lambda fm: super( # type: ignore[method-assign] |
1414 | | - MockToolForRuleTests, tool |
1415 | | - )._get_select_keys(fm) |
1416 | | - |
1417 | | - # Act & Assert |
1418 | | - with pytest.raises( |
1419 | | - NotImplementedError, |
1420 | | - match="Unknown location for selected mocktool rules", |
1421 | | - ): |
1422 | | - tool.select_rules(["E501"]) |
| 1406 | + def test_tool_without_selection_support(self) -> None: |
| 1407 | + # Arrange |
| 1408 | + file_manager = MagicMock() |
| 1409 | + tool = MockToolForRuleTests(file_manager=file_manager, selected_rules=[]) |
| 1410 | + # Override to simulate a tool without selection support |
| 1411 | + tool._get_select_keys = lambda fm: super( # type: ignore[method-assign] |
| 1412 | + MockToolForRuleTests, tool |
| 1413 | + )._get_select_keys(fm) |
| 1414 | + |
| 1415 | + # Act & Assert |
| 1416 | + with pytest.raises( |
| 1417 | + UnhandledConfigEntryError, |
| 1418 | + match="Unknown location for selected mocktool rules", |
| 1419 | + ): |
| 1420 | + tool.select_rules(["E501"]) |
1423 | 1421 |
|
1424 | 1422 | class TestDeselectRules: |
1425 | 1423 | class TestWhenRulesAreCurrentlySelected: |
@@ -1472,24 +1470,23 @@ def test_it_returns_false(self) -> None: |
1472 | 1470 | assert result is False |
1473 | 1471 | file_manager.remove_from_list.assert_not_called() |
1474 | 1472 |
|
1475 | | - class TestToolWithoutSelectionSupport: |
1476 | | - def test_it_raises_not_implemented_error(self) -> None: |
1477 | | - # Arrange |
1478 | | - file_manager = MagicMock() |
1479 | | - tool = MockToolForRuleTests( |
1480 | | - file_manager=file_manager, selected_rules=["E501"] |
1481 | | - ) |
1482 | | - # Override to simulate a tool without selection support |
1483 | | - tool._get_select_keys = lambda fm: super( # type: ignore[method-assign] |
1484 | | - MockToolForRuleTests, tool |
1485 | | - )._get_select_keys(fm) |
1486 | | - |
1487 | | - # Act & Assert |
1488 | | - with pytest.raises( |
1489 | | - NotImplementedError, |
1490 | | - match="Unknown location for selected mocktool rules", |
1491 | | - ): |
1492 | | - tool.deselect_rules(["E501"]) |
| 1473 | + def test_tool_without_selection_support(self) -> None: |
| 1474 | + # Arrange |
| 1475 | + file_manager = MagicMock() |
| 1476 | + tool = MockToolForRuleTests( |
| 1477 | + file_manager=file_manager, selected_rules=["E501"] |
| 1478 | + ) |
| 1479 | + # Override to simulate a tool without selection support |
| 1480 | + tool._get_select_keys = lambda fm: super( # type: ignore[method-assign] |
| 1481 | + MockToolForRuleTests, tool |
| 1482 | + )._get_select_keys(fm) |
| 1483 | + |
| 1484 | + # Act & Assert |
| 1485 | + with pytest.raises( |
| 1486 | + UnhandledConfigEntryError, |
| 1487 | + match="Unknown location for selected mocktool rules", |
| 1488 | + ): |
| 1489 | + tool.deselect_rules(["E501"]) |
1493 | 1490 |
|
1494 | 1491 | class TestGetSelectedRules: |
1495 | 1492 | def test_it_returns_empty_list_by_default(self) -> None: |
|
0 commit comments