Skip to content

Commit 4788d21

Browse files
committed
Remove support for custom timeout messages
Fixes robotframework#2291
1 parent 47b511f commit 4788d21

File tree

6 files changed

+28
-124
lines changed

6 files changed

+28
-124
lines changed

atest/robot/running/timeouts_with_custom_messages.robot

Lines changed: 15 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,68 +2,31 @@
22
Suite Setup Run Tests ${EMPTY} running/timeouts_with_custom_messages.robot
33
Resource atest_resource.robot
44

5-
*** Variables ***
6-
${DEPRECATED} Using custom timeout messages is deprecated since Robot Framework 3.0.1 and will be removed in future versions.
7-
85
*** Test Cases ***
96
Default Test Timeout Message
10-
${tc} = Check Test Case ${TEST NAME}
11-
Check Log Message ${tc.kws[0].msgs[0]} My customized default test timeout FAIL
12-
Custom message should be deprecated with Test Timeout 0 My customized \${DEFAULT END}
7+
Check Test Case ${TEST NAME}
8+
Using more than one value with timeout should error 0 2 Test Timeout
139

1410
Test Timeout Message
15-
${tc} = Check Test Case ${TEST NAME}
16-
Check Log Message ${tc.kws[0].msgs[0]} My test timeout message FAIL
17-
Custom message should be deprecated with [Timeout] in tests 1 My test timeout message
11+
Check Test Case ${TEST NAME}
12+
Using more than one value with timeout should error 1 2
1813

1914
Test Timeout Message In Multiple Columns
20-
${tc} = Check Test Case ${TEST NAME}
21-
Check Log Message ${tc.kws[0].msgs[0]} My test timeout message in multiple columns FAIL
22-
Custom message should be deprecated with [Timeout] in tests 2 My test timeout message in multiple columns
23-
24-
Test Timeout Message With Variables
25-
${tc} = Check Test Case ${TEST NAME}
26-
Check Log Message ${tc.kws[0].msgs[0]} Test message from variable FAIL
27-
Custom message should be deprecated with [Timeout] in tests 3 Test \${MESSAGE}
15+
Check Test Case ${TEST NAME}
16+
Using more than one value with timeout should error 2 7
2817

2918
Keyword Timeout Message
30-
${tc} = Check Test Case ${TEST NAME}
31-
Check Log Message ${tc.kws[1].kws[0].msgs[0]} My keyword timeout message FAIL
32-
Custom message should be deprecated with [Timeout] in keywords 4 My keyword timeout message
19+
Check Test Case ${TEST NAME}
20+
Using more than one value with timeout should error 3 2
3321

3422
Keyword Timeout Message In Multiple Columns
35-
${tc} = Check Test Case ${TEST NAME}
36-
Check Log Message ${tc.kws[0].kws[0].msgs[0]} My keyword timeout message in multiple columns FAIL
37-
Custom message should be deprecated with [Timeout] in keywords 5 My keyword timeout message in multiple columns
38-
39-
Keyword Timeout Message With Variables
40-
${tc} = Check Test Case ${TEST NAME}
41-
Check Log Message ${tc.kws[0].kws[0].msgs[0]} Keyword message from variable FAIL
42-
Custom message should be deprecated with [Timeout] in keywords 6 Keyword \${MESSAGE}
23+
Check Test Case ${TEST NAME}
24+
Using more than one value with timeout should error 4 7
4325

4426
*** Keywords ***
45-
Custom message should be deprecated with Test Timeout
46-
[Arguments] ${index} ${message}
47-
${path} = Normalize Path ${DATADIR}/running/timeouts_with_custom_messages.robot
48-
${warning} = Catenate Error in file '${path}':
49-
... ${DEPRECATED}
50-
... Message that was used is '${message}'.
51-
Check Log Message @{ERRORS}[${index}] ${warning} WARN
52-
53-
Custom message should be deprecated with [Timeout] in tests
54-
[Arguments] ${index} ${message}
55-
${path} = Normalize Path ${DATADIR}/running/timeouts_with_custom_messages.robot
56-
${warning} = Catenate Error in file '${path}':
57-
... Invalid syntax in test case '${TEST NAME}':
58-
... ${DEPRECATED}
59-
... Message that was used is '${message}'.
60-
Check Log Message @{ERRORS}[${index}] ${warning} WARN
61-
62-
Custom message should be deprecated with [Timeout] in keywords
63-
[Arguments] ${index} ${message}
27+
Using more than one value with timeout should error
28+
[Arguments] ${index} ${count} ${setting}=Timeout
6429
${path} = Normalize Path ${DATADIR}/running/timeouts_with_custom_messages.robot
65-
${warning} = Catenate Error in file '${path}':
66-
... Invalid syntax in keyword '${TEST NAME}':
67-
... ${DEPRECATED}
68-
... Message that was used is '${message}'.
69-
Check Log Message @{ERRORS}[${index}] ${warning} WARN
30+
${error} = Catenate Error in file '${path}':
31+
... Setting '${setting}' accepts only one value, got ${count}.
32+
Check Log Message ${ERRORS}[${index}] ${error} ERROR
Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,33 @@
11
*** Settings ***
2-
Test Timeout 500 milliseconds My customized ${DEFAULT END}
3-
4-
*** Variables ***
5-
${DEFAULT END} default test timeout
6-
${MESSAGE} message from variable
2+
Test Timeout 500 milliseconds Not supported anymore
73

84
*** Test Cases ***
95
Default Test Timeout Message
10-
[Documentation] FAIL My customized default test timeout
11-
Sleep 10
6+
No operation
127

138
Test Timeout Message
14-
[Documentation] FAIL My test timeout message
159
[Timeout] 100 milliseconds My test timeout message
16-
Sleep 10
10+
No operation
1711

1812
Test Timeout Message In Multiple Columns
19-
[Documentation] FAIL My test timeout message in multiple columns
2013
[Timeout] 1 millisecond My test timeout message
2114
... in
2215
... multiple columns
23-
Sleep 10
24-
25-
Test Timeout Message With Variables
26-
[Documentation] FAIL Test ${MESSAGE}
27-
[Timeout] 200 milliseconds Test ${MESSAGE}
28-
Sleep 10
16+
No operation
2917

3018
Keyword Timeout Message
31-
[Documentation] FAIL My keyword timeout message
32-
[Timeout]
33-
Keyword Timeout Message 0.1
34-
Keyword Timeout Message 10
19+
Keyword Timeout Message
3520

3621
Keyword Timeout Message In Multiple Columns
37-
[Documentation] FAIL My keyword timeout message in multiple columns
38-
[Timeout]
39-
Keyword Timeout Message In Multiple Columns 10
40-
41-
Keyword Timeout Message With Variables
42-
[Documentation] FAIL Keyword ${MESSAGE}
43-
[Timeout]
44-
Keyword Timeout Message With Variables
22+
Keyword Timeout Message In Multiple Columns
4523

4624
*** Keywords ***
4725
Keyword Timeout Message
48-
[Arguments] ${secs}
4926
[Timeout] 1 second My keyword timeout message
50-
Sleep ${secs}
27+
No operation
5128

5229
Keyword Timeout Message In Multiple Columns
53-
[Arguments] ${secs}
5430
[Timeout] 111 milliseconds My keyword timeout message
5531
... in
5632
... multiple columns
57-
Sleep ${secs}
58-
59-
Keyword Timeout Message With Variables
60-
[Timeout] ${0.1} sec Keyword ${MESSAGE}
61-
Sleep 5 sec
33+
No operation

src/robot/running/model.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,6 @@ def __init__(self, name='', doc='', tags=None, timeout=None, template=None):
9797
#: when building the test. ``None`` if no is template used.
9898
self.template = template
9999

100-
@setter
101-
def timeout(self, timeout):
102-
"""Test timeout as a :class:`Timeout` instance or ``None``.
103-
104-
This attribute is likely to change in the future.
105-
"""
106-
return Timeout(*timeout) if timeout else None
107-
108100

109101
class TestSuite(model.TestSuite):
110102
"""Represents a single executable test suite.
@@ -236,16 +228,6 @@ def report_invalid_syntax(self, message, level='ERROR'):
236228
% (self.source or '<unknown>', self.name, message), level)
237229

238230

239-
class Timeout(object):
240-
241-
def __init__(self, value, *message):
242-
self.value = value
243-
self.message = ' '.join(message)
244-
245-
def __str__(self):
246-
return self.value
247-
248-
249231
class ResourceFile(object):
250232

251233
def __init__(self, doc='', source=None):
@@ -283,11 +265,6 @@ def __init__(self, name, args=(), doc='', tags=(), return_=None, timeout=None):
283265
def keywords(self, keywords):
284266
return model.Keywords(Keyword, self, keywords)
285267

286-
@setter
287-
def timeout(self, timeout):
288-
"""Keyword timeout as a :class:`Timeout` instance or ``None``."""
289-
return Timeout(*timeout) if timeout else None
290-
291268
@setter
292269
def tags(self, tags):
293270
return model.Tags(tags)

src/robot/running/runner.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ def _add_exit_combine(self):
166166
def _get_timeout(self, test):
167167
if not test.timeout:
168168
return None
169-
return TestTimeout(test.timeout.value, test.timeout.message,
170-
self._variables, rpa=test.parent.rpa)
169+
return TestTimeout(test.timeout, self._variables, rpa=test.parent.rpa)
171170

172171
def _run_setup(self, setup, status, result=None):
173172
if not status.failures:

src/robot/running/timeouts/__init__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@
3232
@py2to3
3333
class _Timeout(Sortable):
3434

35-
def __init__(self, timeout=None, message=None, variables=None):
35+
def __init__(self, timeout=None, variables=None):
3636
self.string = timeout or ''
37-
self.message = message or ''
3837
self.secs = -1
3938
self.starttime = -1
4039
self.error = None
@@ -52,7 +51,6 @@ def replace_variables(self, variables):
5251
return
5352
self.secs = timestr_to_secs(self.string)
5453
self.string = secs_to_timestr(self.secs)
55-
self.message = variables.replace_string(self.message)
5654
except (DataError, ValueError) as err:
5755
self.secs = 0.000001 # to make timeout active
5856
self.error = (u'Setting %s timeout failed: %s'
@@ -96,8 +94,6 @@ def get_message(self):
9694

9795
@property
9896
def _timeout_error(self):
99-
if self.message:
100-
return self.message
10197
return '%s timeout %s exceeded.' % (self.type, self.string)
10298

10399
def __unicode__(self):
@@ -121,10 +117,10 @@ class TestTimeout(_Timeout):
121117
type = 'Test'
122118
_keyword_timeout_occurred = False
123119

124-
def __init__(self, timeout=None, message='', variables=None, rpa=False):
120+
def __init__(self, timeout=None, variables=None, rpa=False):
125121
if rpa:
126122
self.type = 'Task'
127-
_Timeout.__init__(self, timeout, message, variables)
123+
_Timeout.__init__(self, timeout, variables)
128124

129125
def set_keyword_timeout(self, timeout_occurred):
130126
if timeout_occurred:

src/robot/running/userkeywordrunner.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ def _run(self, context, args, result):
9090

9191
def _get_timeout(self, variables=None):
9292
timeout = self._handler.timeout
93-
if not timeout:
94-
return None
95-
timeout = KeywordTimeout(timeout.value, timeout.message, variables)
96-
return timeout
93+
return KeywordTimeout(timeout, variables) if timeout else None
9794

9895
def _resolve_arguments(self, arguments, variables=None):
9996
return self.arguments.resolve(arguments, variables)

0 commit comments

Comments
 (0)