From b4d2e601981bce12a1dd569df2d2cade8f39fa51 Mon Sep 17 00:00:00 2001 From: Vassilii Khachaturov Date: Tue, 18 Mar 2014 15:48:04 +0200 Subject: [PATCH] 7530: gen.test.constfunc_test broken in python3 Use the `in' operator rather than has_key() method to check for environment variables in os.environ. Works on both python2 and python3. --- gramps/gen/test/constfunc_test.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gramps/gen/test/constfunc_test.py b/gramps/gen/test/constfunc_test.py index 0959dffa8..a361d85e2 100644 --- a/gramps/gen/test/constfunc_test.py +++ b/gramps/gen/test/constfunc_test.py @@ -19,8 +19,6 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# $Id$ - """ Unittest for constfunc.py """ from __future__ import print_function @@ -33,13 +31,13 @@ from os import environ as env class Test_has_display(unittest.TestCase): def setUp(self): self.has = constfunc.has_display() - self.display_nonempty = env.has_key('DISPLAY') and bool(env['DISPLAY']) + self.display_nonempty = ('DISPLAY' in env) and bool(env['DISPLAY']) @unittest.skipUnless(constfunc.lin(), "Written for Linux only...") def test_consistent_with_DISPLAY_env(self): assert self.has == self.display_nonempty, \ "has_display(): {}, $DISPLAY: {}".format( - self.has, env['DISPLAY'] if env.has_key('DISPLAY') \ + self.has, env['DISPLAY'] if ('DISPLAY' in env) \ else "(unset)") if __name__ == "__main__":