run separate test on every project instead of one big long test all projects
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 15 Sep 2017 19:51:31 +0300
changeset 1809 3f0a552549d1
parent 1808 b4764ebb352d
child 1810 70768bd1dab3
run separate test on every project instead of one big long test all projects
tests/tools/conftest.py
tests/tools/test_application.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.
--- 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__':