1- from six import text_type as unicode
1+ from six import PY3 , text_type as unicode
22from time import sleep
33
44from decorator import decorate
5+ from moretools import isstring
56
67from robottools import TestRobot
78
@@ -14,6 +15,11 @@ def check_process(func):
1415 which is passed to every test method as ``process`` fixture.
1516 """
1617 def caller (func , self , process , * args , ** kwargs ):
18+ cls = type (self )
19+ # ensure that process was not recreated for some reason
20+ if hasattr (cls , 'process' ):
21+ assert process is cls .process
22+ cls .process = process
1723 # polling returns None as long as process is running
1824 assert process .poll () is None , \
1925 "RemoteRobot process is not running (anymore)."
@@ -57,7 +63,10 @@ def test_bytes_result(self, process, robot_Remote):
5763 def test_string_result (self , process , robot_Remote ):
5864 for value in [1 , 2.3 , 'four' , u'five' ]:
5965 result = robot_Remote .ConvertToString (value )
60- assert isinstance (result , unicode )
66+ # not consistent in current PY2-only robotremoteserver
67+ # (can be str or unicode):
68+ # assert isinstance(result, unicode)
69+ assert isstring (result )
6170 assert result == unicode (value )
6271
6372 @check_process
@@ -74,3 +83,16 @@ def test_StopRemoteServer(self, process, robot_Remote):
7483 process .wait ()
7584 # polling returns None as long as process is running
7685 assert process .poll () is not None
86+
87+ @classmethod
88+ def teardown_class (cls ):
89+ """Ensures that the ``RemoteRobot`` process
90+ is really terminated in the end.
91+ """
92+ if not cls .process .poll ():
93+ cls .process .terminate ()
94+
95+
96+ if PY3 :
97+ # robotremoteserver is not PY3-compatible yet
98+ del TestRemoteRobot
0 commit comments