From 55858e1a9d651018369453de6f72b658e2cffbe4 Mon Sep 17 00:00:00 2001 From: ZyX Date: Thu, 13 Mar 2014 20:05:52 +0400 Subject: [PATCH] Fix tests for new psutil --- tests/test_segments.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/test_segments.py b/tests/test_segments.py index 48fde0c2..bfea4f6a 100644 --- a/tests/test_segments.py +++ b/tests/test_segments.py @@ -169,7 +169,18 @@ class TestCommon(TestCase): def test_user(self): new_os = new_module('os', getpid=lambda: 1) - new_psutil = new_module('psutil', Process=lambda pid: Args(username='def')) + + class Process(object): + def __init__(self, pid): + pass + + def username(self): + return 'def' + + if hasattr(common, 'psutil') and not callable(common.psutil.Process.username): + username = property(username) + + new_psutil = new_module('psutil', Process=Process) pl = Pl() with replace_env('USER', 'def') as segment_info: common.username = False