-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
71 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
"lint:all" = [ | ||
"ruff:lint", | ||
"pylint", | ||
"pyright", | ||
] | ||
pylint = [ | ||
"pylint:run", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,51 @@ | ||
"""Test the comments management.""" | ||
|
||
import unittest | ||
from types import SimpleNamespace | ||
|
||
from pytest_mock import MockerFixture | ||
from ruamel.yaml import YAML | ||
from ruamel.yaml.comments import CommentedMap | ||
|
||
from yamkix.comments import fix_for_issue29 | ||
|
||
|
||
class TestComments(unittest.TestCase): | ||
"""Provide unit tests for the comments package.""" | ||
|
||
def test_fix_for_issue29_when_not_none(self) -> None: | ||
"""Test fix_for_issue29. | ||
When the data.ca.items[key][3] is not None | ||
and hence needs to be changed | ||
""" | ||
sut_key = "sut" | ||
items = {"key1": 0, sut_key: [0, 1, 2, 3]} | ||
sut_ca = SimpleNamespace(items=items) | ||
sut_data = SimpleNamespace(dont="care", ca=sut_ca) | ||
|
||
assert sut_data.ca.items[sut_key][3] is not None | ||
fix_for_issue29(sut_data, sut_key) | ||
assert sut_data.ca.items[sut_key][3] is None | ||
|
||
def test_fix_for_issue29_when_none(self) -> None: | ||
"""Test fix_for_issue29. | ||
When the data.ca.items[key][3] is None | ||
and hence doesn't need to be changed | ||
""" | ||
sut_key = "sut" | ||
items = {"key1": 0, sut_key: [0, 1, 2, None]} | ||
sut_ca = SimpleNamespace(items=items) | ||
sut_data = SimpleNamespace(dont="care", ca=sut_ca) | ||
|
||
assert sut_data.ca.items[sut_key][3] is None | ||
fix_for_issue29(sut_data, sut_key) | ||
assert sut_data.ca.items[sut_key][3] is None | ||
|
||
def test_yamkix_add_eol_comment(self) -> None: | ||
"""Test yamkix_add_eol_comment.""" | ||
inp = """\ | ||
# example | ||
name: | ||
# details | ||
family: Smith # very common | ||
given: Alice # one of the siblings | ||
""" | ||
yaml = YAML() | ||
code = yaml.load(inp) | ||
assert code["family"] == "Smith" | ||
def test_fix_for_issue29_when_not_none(mocker: MockerFixture) -> None: | ||
"""Test fix_for_issue29. | ||
When the data.ca.items[key][3] is not None | ||
and hence needs to be changed | ||
""" | ||
sut_key = "sut" | ||
items = {"key1": 0, sut_key: [0, 1, 2, 3]} | ||
sut_ca = mocker.Mock(spec=CommentedMap, items=items) | ||
sut_data = mocker.Mock(spec=CommentedMap, dont="care", ca=sut_ca) | ||
assert sut_data.ca.items[sut_key][3] is not None | ||
fix_for_issue29(sut_data, sut_key) | ||
assert sut_data.ca.items[sut_key][3] is None | ||
|
||
|
||
def test_fix_for_issue29_when_none(mocker: MockerFixture) -> None: | ||
"""Test fix_for_issue29. | ||
When the data.ca.items[key][3] is None | ||
and hence doesn't need to be changed | ||
""" | ||
sut_key = "sut" | ||
items = {"key1": 0, sut_key: [0, 1, 2, None]} | ||
sut_ca = mocker.Mock(spec=CommentedMap, items=items) | ||
sut_data = mocker.Mock(spec=CommentedMap, dont="care", ca=sut_ca) | ||
assert sut_data.ca.items[sut_key][3] is None | ||
fix_for_issue29(sut_data, sut_key) | ||
assert sut_data.ca.items[sut_key][3] is None | ||
|
||
|
||
def test_yamkix_add_eol_comment() -> None: | ||
"""Test yamkix_add_eol_comment.""" | ||
inp = """\ | ||
# example | ||
name: | ||
# details | ||
family: Smith # very common | ||
given: Alice # one of the siblings | ||
""" | ||
yaml = YAML() | ||
code = yaml.load(inp) | ||
assert code["family"] == "Smith" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.PHONY: test-python-versions | ||
test-python-versions: ## ▶ Run tests for all supported python versions | ||
@echo "Running tests for all supported python versions" | ||
@uv run tox run |