initial test

This commit is contained in:
Roberto Alsina 2020-02-05 17:22:37 -03:00
parent 002c12a2c0
commit e65fd89d65
2 changed files with 15 additions and 1 deletions

10
tests/test_monitor.py Normal file
View File

@ -0,0 +1,10 @@
from xrandroll.monitor import Monitor
def test_parse_pos():
data = [
"eDP connected primary 1920x1080+0+1080 (0x56) normal (normal left inverted right x axis y axis) 309mm x 173mm"
]
m = Monitor(data)
assert m.pos_x == 0
assert m.pos_y == 1080

View File

@ -67,7 +67,11 @@ class Monitor:
self.output = parse.search("{}{:s}", self.header)[0]
modes_data = _split_by_lines_matching("^ [^ ]", data)
fields_data = _split_by_lines_matching(r"^\t[^ ]", modes_data.pop(0))
if modes_data:
fields_data = _split_by_lines_matching(r"^\t[^ ]", modes_data.pop(0))
else:
fields_data = []
self.modes = {}
for m in (Mode(d) for d in modes_data):