tests/tools/conftest.py
branchwxPython4
changeset 3438 24fbd4d1fe80
parent 3437 ce366d67a5b7
child 3442 29dbdb09da2e
equal deleted inserted replaced
3437:ce366d67a5b7 3438:24fbd4d1fe80
     1 #!/usr/bin/env python
       
     2 # -*- coding: utf-8 -*-
       
     3 
       
     4 # This file is part of Beremiz, a Integrated Development Environment for
       
     5 # programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
       
     6 #
       
     7 # Copyright (C) 2017: Andrey Skvortsov
       
     8 #
       
     9 # See COPYING file for copyrights details.
       
    10 #
       
    11 # This program is free software; you can redistribute it and/or
       
    12 # modify it under the terms of the GNU General Public License
       
    13 # as published by the Free Software Foundation; either version 2
       
    14 # of the License, or (at your option) any later version.
       
    15 #
       
    16 # This program is distributed in the hope that it will be useful,
       
    17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    19 # GNU General Public License for more details.
       
    20 #
       
    21 # You should have received a copy of the GNU General Public License
       
    22 # along with this program; if not, write to the Free Software
       
    23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
       
    24 
       
    25 
       
    26 from __future__ import absolute_import
       
    27 import os
       
    28 import sys
       
    29 
       
    30 # import pytest
       
    31 # import xvfbwrapper
       
    32 
       
    33 
       
    34 def init_environment():
       
    35     """Append module root directory to sys.path"""
       
    36     try:
       
    37         import Beremiz as _Beremiz
       
    38     except ImportError:
       
    39         sys.path.append(
       
    40             os.path.abspath(
       
    41                 os.path.join(
       
    42                     os.path.dirname(__file__), '..', '..')
       
    43             )
       
    44         )
       
    45 
       
    46 
       
    47 init_environment()
       
    48 
       
    49 #
       
    50 # Something seems to be broken in Beremiz application,
       
    51 # because after tests in test_application.py during Xvfb shutdown
       
    52 # pytest returns error message:
       
    53 # pytest: Fatal IO error 11 (Die Ressource ist zur Zeit nicht verfügbar) on X server :2821.
       
    54 #
       
    55 # As a result of that pytest returns code 1 as some tests were failed,
       
    56 # but they aren't.
       
    57 #
       
    58 # To avoid this Xvfb is launched and killed not by pytest.
       
    59 # $ Xvfb :42 -screen 0 1280x1024x24 &
       
    60 # $ export DISPLAY=:42
       
    61 # $ pytest --timeout=10 ./tests/tools
       
    62 # $ pkill -9 Xvfb
       
    63 #
       
    64 # TODO: find root of this problem.
       
    65 
       
    66 
       
    67 # vdisplay = None
       
    68 #
       
    69 # @pytest.fixture(scope="session", autouse=True)
       
    70 # def start_xvfb_server(request):
       
    71 #     global vdisplay
       
    72 #     vdisplay = xvfbwrapper.Xvfb(width=1280, height=720)
       
    73 #     vdisplay.start()
       
    74 #     request.addfinalizer(stop_xvfb_server)
       
    75 #
       
    76 # def stop_xvfb_server():
       
    77 #     if vdisplay is not None:
       
    78 #         vdisplay.stop()