From e65fd89d65777e3b9a5e65cbf90d8ba641f7c33e Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Wed, 5 Feb 2020 17:22:37 -0300 Subject: [PATCH] initial test --- tests/test_monitor.py | 10 ++++++++++ xrandroll/monitor.py | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tests/test_monitor.py diff --git a/tests/test_monitor.py b/tests/test_monitor.py new file mode 100644 index 0000000..4fd723e --- /dev/null +++ b/tests/test_monitor.py @@ -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 diff --git a/xrandroll/monitor.py b/xrandroll/monitor.py index b573a6e..a107b6b 100644 --- a/xrandroll/monitor.py +++ b/xrandroll/monitor.py @@ -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):