From 405db681a60776d6e618922cdd70621182a6e053 Mon Sep 17 00:00:00 2001 From: Vassilii Khachaturov Date: Thu, 22 Aug 2013 22:39:17 +0000 Subject: [PATCH] 7009: endless exception loop starting w/o DISPLAY Building testing ground for the bug investigation, after reading the grampsgui.py code... svn: r22908 --- gramps/gen/test/constfunc_test.py | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 gramps/gen/test/constfunc_test.py diff --git a/gramps/gen/test/constfunc_test.py b/gramps/gen/test/constfunc_test.py new file mode 100644 index 000000000..0959dffa8 --- /dev/null +++ b/gramps/gen/test/constfunc_test.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2013 Vassilii Khachaturov +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# $Id$ + +""" Unittest for constfunc.py """ + +from __future__ import print_function + +import unittest +from .. import constfunc + +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']) + + @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') \ + else "(unset)") + +if __name__ == "__main__": + unittest.main()