andrej@1808: #!/usr/bin/env python andrej@1808: # -*- coding: utf-8 -*- andrej@1808: andrej@1808: # This file is part of Beremiz, a Integrated Development Environment for andrej@1808: # programming IEC 61131-3 automates supporting plcopen standard and CanFestival. andrej@1808: # andrej@1808: # Copyright (C) 2017: Andrey Skvortsov andrej@1808: # andrej@1808: # See COPYING file for copyrights details. andrej@1808: # andrej@1808: # This program is free software; you can redistribute it and/or andrej@1808: # modify it under the terms of the GNU General Public License andrej@1808: # as published by the Free Software Foundation; either version 2 andrej@1808: # of the License, or (at your option) any later version. andrej@1808: # andrej@1808: # This program is distributed in the hope that it will be useful, andrej@1808: # but WITHOUT ANY WARRANTY; without even the implied warranty of andrej@1808: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the andrej@1808: # GNU General Public License for more details. andrej@1808: # andrej@1808: # You should have received a copy of the GNU General Public License andrej@1808: # along with this program; if not, write to the Free Software andrej@1808: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. andrej@1808: andrej@1808: import os andrej@1808: import sys andrej@1808: import pytest andrej@1808: import xvfbwrapper andrej@1808: import time andrej@1808: andrej@1808: # append module root directory to sys.path andrej@1808: sys.path.append( andrej@1808: os.path.abspath( andrej@1808: os.path.join( andrej@1808: os.path.dirname(__file__), '..', '..') andrej@1808: ) andrej@1808: ) andrej@1808: andrej@1808: andrej@1808: # andrej@1808: # Something seems to be broken in Beremiz application, andrej@1808: # because after tests in test_application.py during Xvfb shutdown andrej@1808: # pytest returns error message: andrej@1808: # pytest: Fatal IO error 11 (Die Ressource ist zur Zeit nicht verfügbar) on X server :2821. andrej@1808: # andrej@1808: # As a result of that pytest returns code 1 as some tests were failed, andrej@1808: # but they aren't. andrej@1808: # andrej@1808: # To avoid this Xvfb is launched and killed not by pytest. andrej@1808: # $ Xvfb :42 -screen 0 1280x1024x24 & andrej@1808: # $ export DISPLAY=:42 andrej@1809: # $ pytest --timeout=10 ./tests/tools andrej@1808: # $ pkill -9 Xvfb andrej@1808: # andrej@1808: # TODO: find root of this problem. andrej@1808: andrej@1808: andrej@1808: # vdisplay = None andrej@1808: # andrej@1808: # @pytest.fixture(scope="session", autouse=True) andrej@1808: # def start_xvfb_server(request): andrej@1808: # global vdisplay andrej@1808: # vdisplay = xvfbwrapper.Xvfb(width=1280, height=720) andrej@1808: # vdisplay.start() andrej@1808: # request.addfinalizer(stop_xvfb_server) andrej@1808: # andrej@1808: # def stop_xvfb_server(): andrej@1808: # if vdisplay is not None: andrej@1808: # vdisplay.stop()