|
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 import os |
|
26 import sys |
|
27 import pytest |
|
28 import xvfbwrapper |
|
29 import time |
|
30 |
|
31 # append module root directory to sys.path |
|
32 sys.path.append( |
|
33 os.path.abspath( |
|
34 os.path.join( |
|
35 os.path.dirname(__file__), '..', '..') |
|
36 ) |
|
37 ) |
|
38 |
|
39 |
|
40 # |
|
41 # Something seems to be broken in Beremiz application, |
|
42 # because after tests in test_application.py during Xvfb shutdown |
|
43 # pytest returns error message: |
|
44 # pytest: Fatal IO error 11 (Die Ressource ist zur Zeit nicht verfügbar) on X server :2821. |
|
45 # |
|
46 # As a result of that pytest returns code 1 as some tests were failed, |
|
47 # but they aren't. |
|
48 # |
|
49 # To avoid this Xvfb is launched and killed not by pytest. |
|
50 # $ Xvfb :42 -screen 0 1280x1024x24 & |
|
51 # $ export DISPLAY=:42 |
|
52 # $ pytest --timeout=10 ./tests/tools |
|
53 # $ pkill -9 Xvfb |
|
54 # |
|
55 # TODO: find root of this problem. |
|
56 |
|
57 |
|
58 # vdisplay = None |
|
59 # |
|
60 # @pytest.fixture(scope="session", autouse=True) |
|
61 # def start_xvfb_server(request): |
|
62 # global vdisplay |
|
63 # vdisplay = xvfbwrapper.Xvfb(width=1280, height=720) |
|
64 # vdisplay.start() |
|
65 # request.addfinalizer(stop_xvfb_server) |
|
66 # |
|
67 # def stop_xvfb_server(): |
|
68 # if vdisplay is not None: |
|
69 # vdisplay.stop() |