# HG changeset patch # User Andrey Skvortsov # Date 1505494291 -10800 # Node ID 3f0a552549d17a8b23855337becf26092bc91906 # Parent b4764ebb352db1d3f2b0beded6ffde62cc8182bc run separate test on every project instead of one big long test all projects diff -r b4764ebb352d -r 3f0a552549d1 tests/tools/conftest.py --- a/tests/tools/conftest.py Fri Sep 15 19:45:41 2017 +0300 +++ b/tests/tools/conftest.py Fri Sep 15 19:51:31 2017 +0300 @@ -49,7 +49,7 @@ # To avoid this Xvfb is launched and killed not by pytest. # $ Xvfb :42 -screen 0 1280x1024x24 & # $ export DISPLAY=:42 -# $ pytest --timeout=10 ./tests/tools +# $ pytest --timeout=10 ./tests/tools # $ pkill -9 Xvfb # # TODO: find root of this problem. diff -r b4764ebb352d -r 3f0a552549d1 tests/tools/test_application.py --- a/tests/tools/test_application.py Fri Sep 15 19:45:41 2017 +0300 +++ b/tests/tools/test_application.py Fri Sep 15 19:51:31 2017 +0300 @@ -25,9 +25,11 @@ import os import sys import unittest +import pytest import wx import time import traceback +import ddt import conftest import Beremiz @@ -50,6 +52,9 @@ self.app.MainLoop() self.app = None + def setUp(self): + self.app = None + def tearDown(self): if self.app is not None and self.app.frame is not None: self.FinishApp() @@ -71,6 +76,7 @@ time.sleep(0.01) +@ddt.ddt class BeremizApplicationTest(UserApplicationTest): """Test Beremiz as whole application""" def StartApp(self): @@ -102,7 +108,9 @@ self.ProcessEvents() item = self.app.frame.ProjectTree.GetNextVisible(item) - def CheckTestProject(self, project): + def CheckTestProject(self, name): + project = self.GetProjectPath(name) + print "Testing example " + name sys.argv = ["", project] self.StartApp() self.OpenAllProjectElements() @@ -130,23 +138,19 @@ self.StartApp() self.FinishApp() - # @unittest.skip("") - def testOpenExampleProjects(self): - """Opens, builds and runs user PLC examples from tests directory""" - prj = [ - "first_steps", - "logging", - "svgui", - "traffic_lights", - "wxGlade", - "python", - "wiimote", - "wxHMI", - ] - for name in prj: - project = self.GetProjectPath(name) - print "Testing example " + name - self.CheckTestProject(project) + @ddt.data( + "first_steps", + "logging", + "svgui", + "traffic_lights", + "wxGlade", + "python", + "wiimote", + "wxHMI", + ) + @pytest.mark.timeout(30) + def testCheckProject(self, name): + self.CheckTestProject(name) if __name__ == '__main__':