From 968bc453144b8829e454585a9bf1f436edf45e41 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Tue, 12 Aug 2014 01:46:07 +0200 Subject: [PATCH] even tests should not suffer too much from side effects. --- test/test_utils.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/test_utils.py b/test/test_utils.py index 84b966ed..33353de1 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -51,14 +51,15 @@ class TestSetupReadline(unittest.TestCase): self.namespace.sys = sys self.namespace.os = os - assert self.completions('os.path.join') == ['os.path.join'] - assert self.completions('os.path.join().upper') == ['os.path.join().upper'] + try: + assert self.completions('os.path.join') == ['os.path.join'] + assert self.completions('os.path.join().upper') == ['os.path.join().upper'] - c = set(['os.' + d for d in dir(os) if d.startswith('ch')]) - assert set(self.completions('os.ch')) == set(c) - - del self.namespace.sys - del self.namespace.os + c = set(['os.' + d for d in dir(os) if d.startswith('ch')]) + assert set(self.completions('os.ch')) == set(c) + finally: + del self.namespace.sys + del self.namespace.os def test_calls(self): s = 'str(bytes'