Skip to content

Commit

Permalink
Rename test
Browse files Browse the repository at this point in the history
  • Loading branch information
cidrblock committed Sep 12, 2023
1 parent 08e7803 commit dd5034c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
13 changes: 3 additions & 10 deletions src/pip4a/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,12 @@ def in_color(self: Tree, val: ScalarVal) -> str:
"yellow",
)
start = ""
if val == "four":
pass
val_str = str(val)
for ansi in ansis:
matches = getattr(self, ansi)
try:
index = matches.index(val)
except ValueError:
continue

if isinstance(val, type(matches[index])):
if val_str in [str(match) for match in matches]:
start += getattr(Ansi, ansi.upper())

return f"{start}{val}{Ansi.RESET}"
return f"{start}{val_str}{Ansi.RESET}"

@staticmethod
def is_scalar(obj: JSONVal) -> bool:
Expand Down
9 changes: 5 additions & 4 deletions tests/unit/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pip4a.tree import JSONVal


sample: JSONVal = {
sample_1: JSONVal = {
"key_one": "one",
"key_two": 42,
"key_three": True,
Expand Down Expand Up @@ -100,10 +100,11 @@
def test_tree_large(monkeypatch: pytest.MonkeyPatch) -> None:
"""Test the tree generator."""
monkeypatch.setenv("NO_COLOR", "true")
assert Tree(sample).render() == result

assert Tree(sample_1).render() == result

sample = {

sample_2: JSONVal = {
"key_one": True,
"key_two": 42,
"key_three": None,
Expand Down Expand Up @@ -132,7 +133,7 @@ def test_tree_large(monkeypatch: pytest.MonkeyPatch) -> None:

def test_tree_color() -> None:
"""Test the tree generator."""
tree = Tree(sample)
tree = Tree(sample_2)
tree.blue = ["key_one", "key_two", "key_three", "key_four"]
tree.green = [True, 42, None, "four"]
rendered = tree.render().splitlines()
Expand Down

0 comments on commit dd5034c

Please sign in to comment.