Skip to content

Commit 33175b5

Browse files
author
Austin Bingham
committed
Getting coverage back up to 100%.
1 parent 7a51a21 commit 33175b5

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

source/yaml_where/path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class PathComponent:
66
@abstractmethod
77
def value(self) -> Any:
8-
pass
8+
"Get the value associated with this path component"
99

1010
def __eq__(self, other):
1111
return self.value() == other.value()

tests/range/test_construction.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from yaml_where.range import Range
23

34

@@ -15,3 +16,8 @@ def test_range_beginning_with_arg():
1516
assert r.start.column == 0
1617
assert r.end.line == 0
1718
assert r.end.column == 5
19+
20+
21+
def test_positions_out_of_order():
22+
with pytest.raises(ValueError):
23+
Range.from_parts(1, 1, 0, 0)

tests/test_null.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
2-
from yaml_where.exceptions import UndefinedAccessError
2+
from yaml_where.exceptions import NoSuchPathError, UndefinedAccessError
3+
from yaml_where.range import Position
34
from yaml_where.yaml_where import YAMLWhere
45

56

@@ -21,4 +22,12 @@ def test_get_value():
2122
yaml = ""
2223
source_map = YAMLWhere.from_string(yaml)
2324
with pytest.raises(UndefinedAccessError):
24-
source_map.get_value_range(0)
25+
source_map.get_value_range(0)
26+
27+
28+
def test_get_path():
29+
yaml = ""
30+
source_map = YAMLWhere.from_string(yaml)
31+
with pytest.raises(NoSuchPathError):
32+
source_map.get_path(Position(0, 0))
33+

tests/test_path.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from yaml_where import path
2+
3+
4+
def test_key_repr():
5+
assert repr(path.Key("key")) == "Key(value=key)"
6+
7+
8+
def test_key_str():
9+
assert str(path.Key("key")) == "key/key"
10+
11+
12+
def test_value_repr():
13+
assert repr(path.Value("value")) == "Value(value=value)"
14+
15+
16+
def test_value_str():
17+
assert str(path.Value("value")) == "value/value"
18+
19+
20+
def test_index_repr():
21+
assert repr(path.Index(0)) == "Index(value=0)"
22+
23+
24+
def test_index_str():
25+
assert str(path.Index(0)) == "index/0"

0 commit comments

Comments
 (0)