Skip to content

Commit f8c2979

Browse files
committed
utests: Use 'assert_(not_)equal' instead of plural versions.
Preparation for removing assert aliases robotframework#2202.
1 parent 1126a22 commit f8c2979

File tree

76 files changed

+1267
-1267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1267
-1267
lines changed

utest/api/test_deco.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import unittest
22

33
from robot.api.deco import keyword
4-
from robot.utils.asserts import assert_equals
4+
from robot.utils.asserts import assert_equal
55

66

77
class TestKeywordName(unittest.TestCase):
@@ -10,23 +10,23 @@ def test_give_name_to_function(self):
1010
@keyword('Given name')
1111
def func():
1212
pass
13-
assert_equals(func.robot_name, 'Given name')
13+
assert_equal(func.robot_name, 'Given name')
1414

1515
def test_give_name_to_method(self):
1616
class Class:
1717
@keyword('Given name')
1818
def method(self):
1919
pass
20-
assert_equals(Class.method.robot_name, 'Given name')
20+
assert_equal(Class.method.robot_name, 'Given name')
2121

2222
def test_no_name(self):
2323
@keyword()
2424
def func():
2525
pass
26-
assert_equals(func.robot_name, None)
26+
assert_equal(func.robot_name, None)
2727

2828
def test_no_name_nor_parens(self):
2929
@keyword
3030
def func():
3131
pass
32-
assert_equals(func.robot_name, None)
32+
assert_equal(func.robot_name, None)

utest/api/test_exposed_api.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,35 @@
44

55
from robot import api, model, parsing, reporting, result, running
66

7-
from robot.utils.asserts import assert_equals
7+
from robot.utils.asserts import assert_equal
88

99

1010
class TestExposedApi(unittest.TestCase):
1111

1212
def test_test_case_file(self):
13-
assert_equals(api.TestCaseFile, parsing.TestCaseFile)
13+
assert_equal(api.TestCaseFile, parsing.TestCaseFile)
1414

1515
def test_test_data_directory(self):
16-
assert_equals(api.TestDataDirectory, parsing.TestDataDirectory)
16+
assert_equal(api.TestDataDirectory, parsing.TestDataDirectory)
1717

1818
def test_resource_file(self):
19-
assert_equals(api.ResourceFile, parsing.ResourceFile)
19+
assert_equal(api.ResourceFile, parsing.ResourceFile)
2020

2121
def test_test_data(self):
22-
assert_equals(api.TestData, parsing.TestData)
22+
assert_equal(api.TestData, parsing.TestData)
2323

2424
def test_execution_result(self):
25-
assert_equals(api.ExecutionResult, result.ExecutionResult)
25+
assert_equal(api.ExecutionResult, result.ExecutionResult)
2626

2727
def test_test_suite(self):
28-
assert_equals(api.TestSuite, running.TestSuite)
28+
assert_equal(api.TestSuite, running.TestSuite)
2929

3030
def test_result_writer(self):
31-
assert_equals(api.ResultWriter, reporting.ResultWriter)
31+
assert_equal(api.ResultWriter, reporting.ResultWriter)
3232

3333
def test_visitors(self):
34-
assert_equals(api.SuiteVisitor, model.SuiteVisitor)
35-
assert_equals(api.ResultVisitor, result.ResultVisitor)
34+
assert_equal(api.SuiteVisitor, model.SuiteVisitor)
35+
assert_equal(api.ResultVisitor, result.ResultVisitor)
3636

3737

3838
class TestTestSuiteBuilder(unittest.TestCase):
@@ -41,11 +41,11 @@ class TestTestSuiteBuilder(unittest.TestCase):
4141

4242
def test_create_with_datasources_as_list(self):
4343
suite = api.TestSuiteBuilder().build(*self.sources)
44-
assert_equals(suite.name, 'Pass And Fail & Normal')
44+
assert_equal(suite.name, 'Pass And Fail & Normal')
4545

4646
def test_create_with_datasource_as_string(self):
4747
suite = api.TestSuiteBuilder().build(self.sources[0])
48-
assert_equals(suite.name, 'Pass And Fail')
48+
assert_equal(suite.name, 'Pass And Fail')
4949

5050

5151
if __name__ == '__main__':

utest/api/test_logging_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
import logging
44

5-
from robot.utils.asserts import assert_equals, assert_true
5+
from robot.utils.asserts import assert_equal, assert_true
66
from robot.api import logger
77

88

@@ -47,8 +47,8 @@ def test_streams(self):
4747
self._verify('to stdout\nto stdout too\n', 'to stderr\n')
4848

4949
def _verify(self, stdout='', stderr=''):
50-
assert_equals(self.stdout.text, stdout)
51-
assert_equals(self.stderr.text, stderr)
50+
assert_equal(self.stdout.text, stdout)
51+
assert_equal(self.stderr.text, stderr)
5252

5353

5454
class MockHandler(logging.Handler):

utest/api/test_run_and_rebot.py

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from robot.model import SuiteVisitor
1414
from robot.running import namespace
1515
from robot.utils import StringIO
16-
from robot.utils.asserts import assert_equals, assert_true
16+
from robot.utils.asserts import assert_equal, assert_true
1717

1818
from resources.runningtestcase import RunningTestCase
1919
from resources.Listener import Listener
@@ -54,78 +54,78 @@ class TestRun(RunningTestCase):
5454
remove_files = [LOG_PATH, REPORT_PATH, OUTPUT_PATH]
5555

5656
def test_run_once(self):
57-
assert_equals(run(self.data, outputdir=TEMP, report='none'), 1)
57+
assert_equal(run(self.data, outputdir=TEMP, report='none'), 1)
5858
self._assert_outputs([('Pass And Fail', 2), (LOG, 1), ('Report:', 0)])
5959
assert exists(LOG_PATH)
6060

6161
def test_run_multiple_times(self):
62-
assert_equals(run_without_outputs(self.data, critical='nomatch'), 0)
63-
assert_equals(run_without_outputs(self.data, name='New Name'), 1)
62+
assert_equal(run_without_outputs(self.data, critical='nomatch'), 0)
63+
assert_equal(run_without_outputs(self.data, name='New Name'), 1)
6464
self._assert_outputs([('Pass And Fail', 2), ('New Name', 2), (LOG, 0)])
6565

6666
def test_run_fail(self):
67-
assert_equals(run(self.data, outputdir=TEMP), 1)
67+
assert_equal(run(self.data, outputdir=TEMP), 1)
6868
self._assert_outputs(stdout=[('Pass And Fail', 2), (LOG, 1)])
6969

7070
def test_run_error(self):
71-
assert_equals(run(self.nonex), 252)
71+
assert_equal(run(self.nonex), 252)
7272
self._assert_outputs(stderr=[('[ ERROR ]', 1), (self.nonex, 1),
7373
('--help', 1)])
7474

7575
def test_custom_stdout(self):
7676
stdout = StringIO()
77-
assert_equals(run_without_outputs(self.data, stdout=stdout), 1)
77+
assert_equal(run_without_outputs(self.data, stdout=stdout), 1)
7878
self._assert_output(stdout, [('Pass And Fail', 2), ('Output:', 1),
7979
('Log:', 0), ('Report:', 0)])
8080
self._assert_outputs()
8181

8282
def test_custom_stderr(self):
8383
stderr = StringIO()
84-
assert_equals(run_without_outputs(self.warn, stderr=stderr), 0)
84+
assert_equal(run_without_outputs(self.warn, stderr=stderr), 0)
8585
self._assert_output(stderr, [('[ WARN ]', 4), ('[ ERROR ]', 2)])
8686
self._assert_outputs([('Warnings And Errors', 2), ('Output:', 1),
8787
('Log:', 0), ('Report:', 0)])
8888

8989
def test_custom_stdout_and_stderr_with_minimal_implementation(self):
9090
output = StreamWithOnlyWriteAndFlush()
91-
assert_equals(run_without_outputs(self.warn, stdout=output, stderr=output), 0)
91+
assert_equal(run_without_outputs(self.warn, stdout=output, stderr=output), 0)
9292
self._assert_output(output, [('[ WARN ]', 4), ('[ ERROR ]', 2),
9393
('Warnings And Errors', 3), ('Output:', 1),
9494
('Log:', 0), ('Report:', 0)])
9595
self._assert_outputs()
9696

9797
def test_multi_options_as_single_string(self):
98-
assert_equals(run_without_outputs(self.data, exclude='fail'), 0)
98+
assert_equal(run_without_outputs(self.data, exclude='fail'), 0)
9999
self._assert_outputs([('FAIL', 0)])
100100

101101
def test_listener_gets_notification_about_log_report_and_output(self):
102102
listener = join(ROOT, 'utest', 'resources', 'Listener.py')
103-
assert_equals(run(self.data, output=OUTPUT_PATH, report=REPORT_PATH,
103+
assert_equal(run(self.data, output=OUTPUT_PATH, report=REPORT_PATH,
104104
log=LOG_PATH, listener=listener), 1)
105105
self._assert_outputs(stdout=[('[output {0}]'.format(OUTPUT_PATH), 1),
106106
('[report {0}]'.format(REPORT_PATH), 1),
107107
('[log {0}]'.format(LOG_PATH), 1),
108108
('[listener close]', 1)])
109109

110110
def test_pass_listener_as_instance(self):
111-
assert_equals(run_without_outputs(self.data, listener=Listener(1)), 1)
111+
assert_equal(run_without_outputs(self.data, listener=Listener(1)), 1)
112112
self._assert_outputs([("[from listener 1]", 1)])
113113

114114
def test_pass_listener_as_string(self):
115115
module_file = join(ROOT, 'utest', 'resources', 'Listener.py')
116-
assert_equals(run_without_outputs(self.data, listener=module_file+":1"), 1)
116+
assert_equal(run_without_outputs(self.data, listener=module_file+":1"), 1)
117117
self._assert_outputs([("[from listener 1]", 1)])
118118

119119
def test_pass_listener_as_list(self):
120120
module_file = join(ROOT, 'utest', 'resources', 'Listener.py')
121-
assert_equals(run_without_outputs(self.data, listener=[module_file+":1", Listener(2)]), 1)
121+
assert_equal(run_without_outputs(self.data, listener=[module_file+":1", Listener(2)]), 1)
122122
self._assert_outputs([("[from listener 1]", 1), ("[from listener 2]", 1)])
123123

124124
def test_pre_run_modifier_as_instance(self):
125125
class Modifier(SuiteVisitor):
126126
def start_suite(self, suite):
127127
suite.tests = [t for t in suite.tests if t.tags.match('pass')]
128-
assert_equals(run_without_outputs(self.data, prerunmodifier=Modifier()), 0)
128+
assert_equal(run_without_outputs(self.data, prerunmodifier=Modifier()), 0)
129129
self._assert_outputs([('Pass ', 1), ('Fail :: FAIL', 0)])
130130

131131
def test_pre_rebot_modifier_as_instance(self):
@@ -135,12 +135,12 @@ def __init__(self):
135135
def visit_test(self, test):
136136
self.tests.append(test.name)
137137
modifier = Modifier()
138-
assert_equals(run(self.data, outputdir=TEMP, log=LOG_PATH, prerebotmodifier=modifier), 1)
139-
assert_equals(modifier.tests, ['Pass', 'Fail'])
138+
assert_equal(run(self.data, outputdir=TEMP, log=LOG_PATH, prerebotmodifier=modifier), 1)
139+
assert_equal(modifier.tests, ['Pass', 'Fail'])
140140
self._assert_outputs([('Pass ', 1), ('Fail :: FAIL', 1)])
141141

142142
def test_invalid_modifier(self):
143-
assert_equals(run_without_outputs(self.data, prerunmodifier=42), 1)
143+
assert_equal(run_without_outputs(self.data, prerunmodifier=42), 1)
144144
self._assert_outputs([('Pass ', 1), ('Fail :: FAIL', 1)],
145145
[("[ ERROR ] Executing model modifier 'integer' "
146146
"failed: AttributeError: ", 1)])
@@ -153,34 +153,34 @@ class TestRebot(RunningTestCase):
153153
remove_files = [LOG_PATH, REPORT_PATH]
154154

155155
def test_run_once(self):
156-
assert_equals(rebot(self.data, outputdir=TEMP, report='NONE'), 1)
156+
assert_equal(rebot(self.data, outputdir=TEMP, report='NONE'), 1)
157157
self._assert_outputs([(LOG, 1), ('Report:', 0)])
158158
assert exists(LOG_PATH)
159159

160160
def test_run_multiple_times(self):
161-
assert_equals(rebot(self.data, outputdir=TEMP, critical='nomatch'), 0)
162-
assert_equals(rebot(self.data, outputdir=TEMP, name='New Name'), 1)
161+
assert_equal(rebot(self.data, outputdir=TEMP, critical='nomatch'), 0)
162+
assert_equal(rebot(self.data, outputdir=TEMP, name='New Name'), 1)
163163
self._assert_outputs([(LOG, 2)])
164164

165165
def test_run_fails(self):
166-
assert_equals(rebot(self.nonex), 252)
167-
assert_equals(rebot(self.data, outputdir=TEMP), 1)
166+
assert_equal(rebot(self.nonex), 252)
167+
assert_equal(rebot(self.data, outputdir=TEMP), 1)
168168
self._assert_outputs(stdout=[(LOG, 1)],
169169
stderr=[('[ ERROR ]', 1), (self.nonex, (1, 2)),
170170
('--help', 1)])
171171

172172
def test_custom_stdout(self):
173173
stdout = StringIO()
174-
assert_equals(rebot(self.data, report='None', stdout=stdout,
174+
assert_equal(rebot(self.data, report='None', stdout=stdout,
175175
outputdir=TEMP), 1)
176176
self._assert_output(stdout, [('Log:', 1), ('Report:', 0)])
177177
self._assert_outputs()
178178

179179
def test_custom_stdout_and_stderr_with_minimal_implementation(self):
180180
output = StreamWithOnlyWriteAndFlush()
181-
assert_equals(rebot(self.data, log='NONE', report='NONE', stdout=output,
181+
assert_equal(rebot(self.data, log='NONE', report='NONE', stdout=output,
182182
stderr=output), 252)
183-
assert_equals(rebot(self.data, report='NONE', stdout=output,
183+
assert_equal(rebot(self.data, report='NONE', stdout=output,
184184
stderr=output, outputdir=TEMP), 1)
185185
self._assert_output(output, [('[ ERROR ] No outputs created', 1),
186186
('--help', 1), ('Log:', 1), ('Report:', 0)])
@@ -194,9 +194,9 @@ def visit_test(self, test):
194194
self.tests.append(test.name)
195195
test.status = 'FAIL'
196196
modifier = Modifier()
197-
assert_equals(rebot(self.data, outputdir=TEMP,
197+
assert_equal(rebot(self.data, outputdir=TEMP,
198198
prerebotmodifier=modifier), 3)
199-
assert_equals(modifier.tests, ['Test 1.1', 'Test 1.2', 'Test 2.1'])
199+
assert_equal(modifier.tests, ['Test 1.1', 'Test 1.2', 'Test 2.1'])
200200

201201

202202
class TestStateBetweenTestRuns(RunningTestCase):
@@ -223,23 +223,23 @@ def _import_resource(self):
223223
def test_clear_namespace_between_runs(self):
224224
data = join(ROOT, 'atest', 'testdata', 'variables', 'commandline_variables.robot')
225225
rc = self._run(data, test=['NormalText'], variable=['NormalText:Hello'])
226-
assert_equals(rc, 0)
226+
assert_equal(rc, 0)
227227
rc = self._run(data, test=['NormalText'])
228-
assert_equals(rc, 1)
228+
assert_equal(rc, 1)
229229

230230
def test_reset_logging_conf(self):
231-
assert_equals(logging.getLogger().handlers, [])
232-
assert_equals(logging.raiseExceptions, 1)
231+
assert_equal(logging.getLogger().handlers, [])
232+
assert_equal(logging.raiseExceptions, 1)
233233
self._run(join(ROOT, 'atest', 'testdata', 'misc', 'normal.robot'))
234-
assert_equals(logging.getLogger().handlers, [])
235-
assert_equals(logging.raiseExceptions, 1)
234+
assert_equal(logging.getLogger().handlers, [])
235+
assert_equal(logging.raiseExceptions, 1)
236236

237237
def test_listener_unregistration(self):
238238
listener = join(ROOT, 'utest', 'resources', 'Listener.py')
239-
assert_equals(run_without_outputs(self.data, listener=listener+':1'), 0)
239+
assert_equal(run_without_outputs(self.data, listener=listener+':1'), 0)
240240
self._assert_outputs([("[from listener 1]", 1), ("[listener close]", 1)])
241241
self._clear_outputs()
242-
assert_equals(run_without_outputs(self.data), 0)
242+
assert_equal(run_without_outputs(self.data), 0)
243243
self._assert_outputs([("[from listener 1]", 0), ("[listener close]", 0)])
244244

245245

@@ -259,19 +259,19 @@ def test_different_timestamps_when_run_multiple_times(self):
259259
output21, output22 = self.find_results(self.output, 2)
260260
report21, report22 = self.find_results(self.report, 2)
261261
log21, log22 = self.find_results(self.log, 2)
262-
assert_equals(output1, output21)
263-
assert_equals(report1, report21)
264-
assert_equals(log1, log21)
262+
assert_equal(output1, output21)
263+
assert_equal(report1, report21)
264+
assert_equal(log1, log21)
265265

266266
def run_tests(self):
267267
data = join(ROOT, 'atest', 'testdata', 'misc', 'pass_and_fail.robot')
268-
assert_equals(run(data, timestampoutputs=True, outputdir=TEMP,
268+
assert_equal(run(data, timestampoutputs=True, outputdir=TEMP,
269269
output='output-ts.xml', report='report-ts.html',
270270
log='log-ts'), 1)
271271

272272
def find_results(self, pattern, expected):
273273
matches = glob.glob(pattern)
274-
assert_equals(len(matches), expected)
274+
assert_equal(len(matches), expected)
275275
return sorted(matches)
276276

277277
def wait_until_next_second(self):
@@ -290,8 +290,8 @@ def test_original_signal_handlers_are_restored(self):
290290
signal.signal(signal.SIGTERM, my_sigterm)
291291
try:
292292
run_without_outputs(self.data, stdout=StringIO())
293-
assert_equals(signal.getsignal(signal.SIGINT), orig_sigint)
294-
assert_equals(signal.getsignal(signal.SIGTERM), my_sigterm)
293+
assert_equal(signal.getsignal(signal.SIGINT), orig_sigint)
294+
assert_equal(signal.getsignal(signal.SIGTERM), my_sigterm)
295295
finally:
296296
signal.signal(signal.SIGINT, orig_sigint)
297297
signal.signal(signal.SIGTERM, orig_sigterm)

utest/api/test_using_libraries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import unittest
22

3-
from robot.utils.asserts import assert_equals, assert_raises_with_msg
3+
from robot.utils.asserts import assert_equal, assert_raises_with_msg
44
from robot.libraries.BuiltIn import BuiltIn, RobotNotRunningError
55
from robot.libraries.DateTime import Date
66

@@ -30,7 +30,7 @@ class TestDateTime(unittest.TestCase):
3030

3131
def test_date_seconds(self):
3232
secs = 1234567890
33-
assert_equals(Date(secs).seconds, secs)
33+
assert_equal(Date(secs).seconds, secs)
3434

3535

3636
if __name__ == '__main__':

0 commit comments

Comments
 (0)