From 328b8ccfa36a090f73ee99d4a7e1e13312e1e12e Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Wed, 5 Feb 2020 17:39:52 -0300 Subject: [PATCH] Some more tests --- tests/fixtures/{sample1.txt => sample_1.txt} | 0 tests/test_xrandr.py | 8 ++++++++ xrandroll/xrandr.py | 6 +----- 3 files changed, 9 insertions(+), 5 deletions(-) rename tests/fixtures/{sample1.txt => sample_1.txt} (100%) create mode 100644 tests/test_xrandr.py diff --git a/tests/fixtures/sample1.txt b/tests/fixtures/sample_1.txt similarity index 100% rename from tests/fixtures/sample1.txt rename to tests/fixtures/sample_1.txt diff --git a/tests/test_xrandr.py b/tests/test_xrandr.py new file mode 100644 index 0000000..647f446 --- /dev/null +++ b/tests/test_xrandr.py @@ -0,0 +1,8 @@ +from xrandroll.xrandr import parse_data + + +def test_parse_data(test_data): + data = test_data.read("sample_1.txt", deserialize=False).splitlines() + monitors = parse_data(data) + assert len(monitors) == 2 + assert [m.output for m in monitors] == ["eDP", "HDMI-A-0"] diff --git a/xrandroll/xrandr.py b/xrandroll/xrandr.py index d55a8bb..9f3e2a1 100644 --- a/xrandroll/xrandr.py +++ b/xrandroll/xrandr.py @@ -2,7 +2,7 @@ import subprocess -from monitor import Monitor, _split_by_lines_matching +from .monitor import Monitor, _split_by_lines_matching def read_data(): @@ -20,7 +20,3 @@ def parse_data(data): for monitor_data in _split_by_lines_matching(r"^[^ \t].*", screen[1:]): result.append(Monitor(monitor_data)) return result - - -if __name__ == "__main__": - print(parse_data(read_data()))