From 57152a8e29d951c2447a83f5bcf5c43f3163d106 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 5 Oct 2021 11:41:18 +0530 Subject: [PATCH] Fix utmp test --- kitty_tests/utmp.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/kitty_tests/utmp.py b/kitty_tests/utmp.py index 2105ba13a..10b7f7d5b 100644 --- a/kitty_tests/utmp.py +++ b/kitty_tests/utmp.py @@ -1,13 +1,14 @@ -from sys import platform +import subprocess +from kitty.fast_data_types import num_users +from . import BaseTest -if platform in ('linux', 'linux2'): - import subprocess - import re - from kitty.fast_data_types import num_users - from . import BaseTest - class UTMPTest(BaseTest): - def test_num_users(self): - # who -q is the control - expected = subprocess.run(['who'], capture_output=True).stdout.decode('utf-8').count('\n') - self.ae(num_users(), expected) +class UTMPTest(BaseTest): + + def test_num_users(self): + # who is the control + try: + expected = subprocess.check_output(['who']).decode('utf-8').count('\n') + except FileNotFoundError: + self.skipTest('No who executable cannot verify num_users') + self.ae(num_users(), expected)