Merge lp:~trb143/openlp/asserts into lp:openlp

Proposed by Tim Bentley
Status: Superseded
Proposed branch: lp:~trb143/openlp/asserts
Merge into: lp:openlp
Diff against target: 1134 lines (+167/-171)
17 files modified
tests/functional/openlp_core/api/http/test_error.py (+4/-4)
tests/functional/openlp_core/api/http/test_http.py (+4/-4)
tests/functional/openlp_core/api/http/test_wsgiapp.py (+3/-3)
tests/functional/openlp_core/api/test_deploy.py (+1/-1)
tests/functional/openlp_core/api/test_tab.py (+11/-12)
tests/functional/openlp_core/api/test_websockets.py (+15/-16)
tests/functional/openlp_core/common/test_actions.py (+17/-17)
tests/functional/openlp_core/common/test_common.py (+18/-17)
tests/functional/openlp_core/common/test_httputils.py (+6/-6)
tests/functional/openlp_core/common/test_init.py (+25/-26)
tests/functional/openlp_core/common/test_json.py (+6/-6)
tests/functional/openlp_core/common/test_mixins.py (+4/-4)
tests/functional/openlp_core/common/test_path.py (+17/-18)
tests/functional/openlp_core/common/test_projector_utilities.py (+14/-14)
tests/functional/openlp_core/common/test_registry.py (+16/-16)
tests/functional/openlp_core/common/test_settings.py (+5/-6)
tests/functional/openlp_core/ui/test_mainwindow.py (+1/-1)
To merge this branch: bzr merge lp:~trb143/openlp/asserts
Reviewer Review Type Date Requested Status
Phill Needs Fixing
Review via email: mp+335002@code.launchpad.net

This proposal has been superseded by a proposal from 2017-12-15.

To post a comment you must log in.
Revision history for this message
Phill (phill-ridout) wrote :

generally ok, but there's several assert statements where you have change the meaning, checking for Falsey/Truthy values rather than checking that the the result is True, is False, is None, etc.

I've highlight a few with inline comments, but there are some others.

review: Needs Fixing
lp:~trb143/openlp/asserts updated
2807. By Tim Bentley

fixes

2808. By Tim Bentley

fixes

2809. By Tim Bentley

fixes

2810. By Tim Bentley

head

2811. By Tim Bentley

2 more done

2812. By Tim Bentley

1 more done

2813. By Tim Bentley

lib done

2814. By Tim Bentley

lib done pep 8

2815. By Tim Bentley

Fixes

2816. By Tim Bentley

head

2817. By Tim Bentley

buttons and app

2818. By Tim Bentley

fix up widgets

2819. By Tim Bentley

Start media

2820. By Tim Bentley

ui media done

2821. By Tim Bentley

pep8

2822. By Tim Bentley

start ui

2823. By Tim Bentley

start ui 2

2824. By Tim Bentley

more ui bits

2825. By Tim Bentley

more ui bits

2826. By Tim Bentley

Fix tests and make pytest run clean

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/functional/openlp_core/api/http/test_error.py'
2--- tests/functional/openlp_core/api/http/test_error.py 2017-03-04 19:17:59 +0000
3+++ tests/functional/openlp_core/api/http/test_error.py 2017-12-15 16:30:32 +0000
4@@ -42,8 +42,8 @@
5 raise NotFound()
6
7 # THEN: we get an error and a status
8- self.assertEquals('Not Found', context.exception.message, 'A Not Found exception should be thrown')
9- self.assertEquals(404, context.exception.status, 'A 404 status should be thrown')
10+ assert 'Not Found' == context.exception.message, 'A Not Found exception should be thrown'
11+ assert 404 == context.exception.status, 'A 404 status should be thrown'
12
13 def test_server_error(self):
14 """
15@@ -55,5 +55,5 @@
16 raise ServerError()
17
18 # THEN: we get an error and a status
19- self.assertEquals('Server Error', context.exception.message, 'A Not Found exception should be thrown')
20- self.assertEquals(500, context.exception.status, 'A 500 status should be thrown')
21+ assert'Server Error' == context.exception.message, 'A Not Found exception should be thrown'
22+ assert 500 == context.exception.status, 'A 500 status should be thrown'
23
24=== modified file 'tests/functional/openlp_core/api/http/test_http.py'
25--- tests/functional/openlp_core/api/http/test_http.py 2017-12-02 10:52:13 +0000
26+++ tests/functional/openlp_core/api/http/test_http.py 2017-12-15 16:30:32 +0000
27@@ -53,8 +53,8 @@
28 HttpServer()
29
30 # THEN: the api environment should have been created
31- self.assertEquals(1, mock_qthread.call_count, 'The qthread should have been called once')
32- self.assertEquals(1, mock_thread.call_count, 'The http thread should have been called once')
33+ assert mock_qthread.call_count == 1, 'The qthread should have been called once'
34+ assert mock_thread.call_count == 1, 'The http thread should have been called once'
35
36 @patch('openlp.core.api.http.server.HttpWorker')
37 @patch('openlp.core.api.http.server.QtCore.QThread')
38@@ -68,5 +68,5 @@
39 HttpServer()
40
41 # THEN: the api environment should have been created
42- self.assertEquals(0, mock_qthread.call_count, 'The qthread should not have have been called')
43- self.assertEquals(0, mock_thread.call_count, 'The http thread should not have been called')
44+ assert mock_qthread.call_count == 0, 'The qthread should not have have been called'
45+ assert mock_thread.call_count == 0, 'The http thread should not have been called'
46
47=== modified file 'tests/functional/openlp_core/api/http/test_wsgiapp.py'
48--- tests/functional/openlp_core/api/http/test_wsgiapp.py 2017-08-12 20:08:12 +0000
49+++ tests/functional/openlp_core/api/http/test_wsgiapp.py 2017-12-15 16:30:32 +0000
50@@ -61,7 +61,7 @@
51 application.dispatch(rqst)
52
53 # THEN: the not found returned
54- self.assertEqual(context.exception.args[0], 'Not Found', 'URL not found in dispatcher')
55+ assert context.exception.args[0] == 'Not Found', 'URL not found in dispatcher'
56
57 # WHEN: when the URL is correct and dispatch called
58 rqst = MagicMock()
59@@ -69,8 +69,8 @@
60 rqst.method = 'GET'
61 application.dispatch(rqst)
62 # THEN: the not found id called
63- self.assertEqual(1, application.route_map['^\\/test\\/image$']['GET'].call_count,
64- 'main_index function should have been called')
65+ assert 1 == application.route_map['^\\/test\\/image$']['GET'].call_count, \
66+ 'main_index function should have been called'
67
68
69 @test_endpoint.route('image')
70
71=== modified file 'tests/functional/openlp_core/api/test_deploy.py'
72--- tests/functional/openlp_core/api/test_deploy.py 2017-11-18 11:23:15 +0000
73+++ tests/functional/openlp_core/api/test_deploy.py 2017-12-15 16:30:32 +0000
74@@ -58,4 +58,4 @@
75 deploy_zipfile(self.app_root_path, 'site.zip')
76
77 # THEN: test if www directory has been created
78- self.assertTrue((self.app_root_path / 'www').is_dir(), 'We should have a www directory')
79+ assert (self.app_root_path / 'www').is_dir(), 'We should have a www directory'
80
81=== modified file 'tests/functional/openlp_core/api/test_tab.py'
82--- tests/functional/openlp_core/api/test_tab.py 2017-10-10 07:08:44 +0000
83+++ tests/functional/openlp_core/api/test_tab.py 2017-12-15 16:30:32 +0000
84@@ -81,8 +81,8 @@
85 # WHEN: the default ip address is given
86 ip_address = self.form.get_ip_address(ZERO_URL)
87 # THEN: the default ip address will be returned
88- self.assertTrue(re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', ip_address),
89- 'The return value should be a valid ip address')
90+ assert re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', ip_address), \
91+ 'The return value should be a valid ip address'
92
93 def test_get_ip_address_with_ip(self):
94 """
95@@ -93,7 +93,7 @@
96 # WHEN: the default ip address is given
97 ip_address = self.form.get_ip_address(given_ip)
98 # THEN: the default ip address will be returned
99- self.assertEqual(ip_address, given_ip, 'The return value should be %s' % given_ip)
100+ assert ip_address == given_ip, 'The return value should be %s' % given_ip
101
102 def test_set_urls(self):
103 """
104@@ -104,12 +104,11 @@
105 # WHEN: the urls are generated
106 self.form.set_urls()
107 # THEN: the following links are returned
108- self.assertEqual(self.form.remote_url.text(),
109- "<a href=\"http://192.168.1.1:4316/\">http://192.168.1.1:4316/</a>",
110- 'The return value should be a fully formed link')
111- self.assertEqual(self.form.stage_url.text(),
112- "<a href=\"http://192.168.1.1:4316/stage\">http://192.168.1.1:4316/stage</a>",
113- 'The return value should be a fully formed stage link')
114- self.assertEqual(self.form.live_url.text(),
115- "<a href=\"http://192.168.1.1:4316/main\">http://192.168.1.1:4316/main</a>",
116- 'The return value should be a fully formed main link')
117+ assert self.form.remote_url.text() == "<a href=\"http://192.168.1.1:4316/\">http://192.168.1.1:4316/</a>", \
118+ 'The return value should be a fully formed link'
119+ assert self.form.stage_url.text() == \
120+ "<a href=\"http://192.168.1.1:4316/stage\">http://192.168.1.1:4316/stage</a>", \
121+ 'The return value should be a fully formed stage link'
122+ assert self.form.live_url.text() == \
123+ "<a href=\"http://192.168.1.1:4316/main\">http://192.168.1.1:4316/main</a>", \
124+ 'The return value should be a fully formed main link'
125
126=== modified file 'tests/functional/openlp_core/api/test_websockets.py'
127--- tests/functional/openlp_core/api/test_websockets.py 2017-12-02 09:31:13 +0000
128+++ tests/functional/openlp_core/api/test_websockets.py 2017-12-15 16:30:32 +0000
129@@ -74,8 +74,8 @@
130 WebSocketServer()
131
132 # THEN: the api environment should have been created
133- self.assertEquals(1, mock_qthread.call_count, 'The qthread should have been called once')
134- self.assertEquals(1, mock_worker.call_count, 'The http thread should have been called once')
135+ assert mock_qthread.call_count == 1, 'The qthread should have been called once'
136+ assert mock_worker.call_count == 1, 'The http thread should have been called once'
137
138 @patch('openlp.core.api.websockets.WebSocketWorker')
139 @patch('openlp.core.api.websockets.QtCore.QThread')
140@@ -89,8 +89,8 @@
141 WebSocketServer()
142
143 # THEN: the api environment should have been created
144- self.assertEquals(0, mock_qthread.call_count, 'The qthread should not have been called')
145- self.assertEquals(0, mock_worker.call_count, 'The http thread should not have been called')
146+ assert mock_qthread.call_count == 0, 'The qthread should not have been called'
147+ assert mock_worker.call_count == 0, 'The http thread should not have been called'
148
149 def test_main_poll(self):
150 """
151@@ -102,8 +102,7 @@
152 Registry().register('live_controller', mocked_live_controller)
153 # THEN: the live json should be generated
154 main_json = self.poll.main_poll()
155- self.assertEquals(b'{"results": {"slide_count": 5}}', main_json,
156- 'The return value should match the defined json')
157+ assert b'{"results": {"slide_count": 5}}' == main_json, 'The return value should match the defined json'
158
159 def test_poll(self):
160 """
161@@ -130,13 +129,13 @@
162 mocked_is_chords_active.return_value = True
163 poll_json = self.poll.poll()
164 # THEN: the live json should be generated and match expected results
165- self.assertTrue(poll_json['results']['blank'], 'The blank return value should be True')
166- self.assertFalse(poll_json['results']['theme'], 'The theme return value should be False')
167- self.assertFalse(poll_json['results']['display'], 'The display return value should be False')
168- self.assertFalse(poll_json['results']['isSecure'], 'The isSecure return value should be False')
169- self.assertFalse(poll_json['results']['isAuthorised'], 'The isAuthorised return value should be False')
170- self.assertTrue(poll_json['results']['twelve'], 'The twelve return value should be False')
171- self.assertEquals(poll_json['results']['version'], 3, 'The version return value should be 3')
172- self.assertEquals(poll_json['results']['slide'], 5, 'The slide return value should be 5')
173- self.assertEquals(poll_json['results']['service'], 21, 'The version return value should be 21')
174- self.assertEquals(poll_json['results']['item'], '23-34-45', 'The item return value should match 23-34-45')
175+ assert poll_json['results']['blank'] is True, 'The blank return value should be True'
176+ assert poll_json['results']['theme'] is False, 'The theme return value should be False'
177+ assert poll_json['results']['display'] is False, 'The display return value should be False'
178+ assert poll_json['results']['isSecure'] is False, 'The isSecure return value should be False'
179+ assert poll_json['results']['isAuthorised'] is False, 'The isAuthorised return value should be False'
180+ assert poll_json['results']['twelve'] is True, 'The twelve return value should be True'
181+ assert poll_json['results']['version'] == 3, 'The version return value should be 3'
182+ assert poll_json['results']['slide'] == 5, 'The slide return value should be 5'
183+ assert poll_json['results']['service'] == 21, 'The version return value should be 21'
184+ assert poll_json['results']['item'] == '23-34-45', 'The item return value should match 23-34-45'
185
186=== modified file 'tests/functional/openlp_core/common/test_actions.py'
187--- tests/functional/openlp_core/common/test_actions.py 2017-11-03 22:52:24 +0000
188+++ tests/functional/openlp_core/common/test_actions.py 2017-12-15 16:30:32 +0000
189@@ -59,8 +59,8 @@
190 self.list.append(self.action1)
191
192 # THEN: The actions should (not) be in the list.
193- self.assertTrue(self.action1 in self.list)
194- self.assertFalse(self.action2 in self.list)
195+ assert self.action1 in self.list
196+ assert self.action2 not in self.list
197
198 def test_len(self):
199 """
200@@ -69,14 +69,14 @@
201 # GIVEN: The list.
202 # WHEN: Do nothing.
203 # THEN: Check the length.
204- self.assertEqual(len(self.list), 0, "The length should be 0.")
205+ assert len(self.list) == 0, "The length should be 0."
206
207 # GIVEN: The list.
208 # WHEN: Append an action.
209 self.list.append(self.action1)
210
211 # THEN: Check the length.
212- self.assertEqual(len(self.list), 1, "The length should be 1.")
213+ assert len(self.list) == 1, "The length should be 1."
214
215 def test_append(self):
216 """
217@@ -88,10 +88,10 @@
218 self.list.append(self.action2)
219
220 # THEN: Check if the actions are in the list and check if they have the correct weights.
221- self.assertTrue(self.action1 in self.list)
222- self.assertTrue(self.action2 in self.list)
223- self.assertEqual(self.list.actions[0], (0, self.action1))
224- self.assertEqual(self.list.actions[1], (1, self.action2))
225+ assert self.action1 in self.list
226+ assert self.action2 in self.list
227+ assert self.list.actions[0] == (0, self.action1)
228+ assert self.list.actions[1] == (1, self.action2)
229
230 def test_add(self):
231 """
232@@ -106,11 +106,11 @@
233 self.list.add(self.action2, action2_weight)
234
235 # THEN: Check if they were added and have the specified weights.
236- self.assertTrue(self.action1 in self.list)
237- self.assertTrue(self.action2 in self.list)
238+ assert self.action1 in self.list
239+ assert self.action2 in self.list
240 # Now check if action1 is second and action2 is first (due to their weights).
241- self.assertEqual(self.list.actions[0], (41, self.action2))
242- self.assertEqual(self.list.actions[1], (42, self.action1))
243+ assert self.list.actions[0] == (41, self.action2)
244+ assert self.list.actions[1] == (42, self.action1)
245
246 def test_iterator(self):
247 """
248@@ -121,11 +121,11 @@
249 self.list.add(self.action2)
250
251 # WHEN: Iterating over the list
252- list = [a for a in self.list]
253+ local_list = [a for a in self.list]
254 # THEN: Make sure they are returned in correct order
255- self.assertEquals(len(self.list), 2)
256- self.assertIs(list[0], self.action1)
257- self.assertIs(list[1], self.action2)
258+ assert len(self.list) == 2
259+ assert local_list[0] is self.action1
260+ assert local_list[1] is self.action2
261
262 def test_remove(self):
263 """
264@@ -138,7 +138,7 @@
265 self.list.remove(self.action1)
266
267 # THEN: Now the element should not be in the list anymore.
268- self.assertFalse(self.action1 in self.list)
269+ assert self.action1 not in self.list
270
271 # THEN: Check if an exception is raised when trying to remove a not present action.
272 self.assertRaises(ValueError, self.list.remove, self.action2)
273
274=== modified file 'tests/functional/openlp_core/common/test_common.py'
275--- tests/functional/openlp_core/common/test_common.py 2017-10-07 07:05:07 +0000
276+++ tests/functional/openlp_core/common/test_common.py 2017-12-15 16:30:32 +0000
277@@ -48,7 +48,7 @@
278 extension_loader('glob', ['file2.py', 'file3.py'])
279
280 # THEN: `extension_loader` should not try to import any files
281- self.assertFalse(mocked_import_module.called)
282+ assert mocked_import_module.called is False
283
284 def test_extension_loader_files_found(self):
285 """
286@@ -69,7 +69,8 @@
287
288 # THEN: `extension_loader` should only try to import the files that are matched by the blob, excluding the
289 # files listed in the `excluded_files` argument
290- mocked_import_module.assert_has_calls([call('openlp.import_dir.file1'), call('openlp.import_dir.file4')])
291+ mocked_import_module.assert_has_calls([call('openlp.import_dir.file1'),
292+ call('openlp.import_dir.file4')])
293
294 def test_extension_loader_import_error(self):
295 """
296@@ -87,7 +88,7 @@
297 extension_loader('glob')
298
299 # THEN: The `ImportError` should be caught and logged
300- self.assertTrue(mocked_logger.warning.called)
301+ assert mocked_logger.warning.called
302
303 def test_extension_loader_os_error(self):
304 """
305@@ -105,7 +106,7 @@
306 extension_loader('glob')
307
308 # THEN: The `OSError` should be caught and logged
309- self.assertTrue(mocked_logger.warning.called)
310+ assert mocked_logger.warning.called
311
312 def test_de_hump_conversion(self):
313 """
314@@ -118,7 +119,7 @@
315 new_string = de_hump(string)
316
317 # THEN: the new string should be converted to python format
318- self.assertEqual(new_string, "my_class", 'The class name should have been converted')
319+ assert new_string == "my_class", 'The class name should have been converted'
320
321 def test_de_hump_static(self):
322 """
323@@ -131,7 +132,7 @@
324 new_string = de_hump(string)
325
326 # THEN: the new string should be converted to python format
327- self.assertEqual(new_string, "my_class", 'The class name should have been preserved')
328+ assert new_string == "my_class", 'The class name should have been preserved'
329
330 def test_path_to_module(self):
331 """
332@@ -144,7 +145,7 @@
333 result = path_to_module(path)
334
335 # THEN: path_to_module should return the module name
336- self.assertEqual(result, 'openlp.core.ui.media.webkitplayer')
337+ assert result == 'openlp.core.ui.media.webkitplayer'
338
339 def test_trace_error_handler(self):
340 """
341@@ -174,9 +175,9 @@
342 mocked_sys.platform = 'win32'
343
344 # THEN: The three platform functions should perform properly
345- self.assertTrue(is_win(), 'is_win() should return True')
346- self.assertFalse(is_macosx(), 'is_macosx() should return False')
347- self.assertFalse(is_linux(), 'is_linux() should return False')
348+ assert is_win(), 'is_win() should return True'
349+ assert is_macosx() is False, 'is_macosx() should return False'
350+ assert is_linux() is False, 'is_linux() should return False'
351
352 def test_is_macosx(self):
353 """
354@@ -190,9 +191,9 @@
355 mocked_sys.platform = 'darwin'
356
357 # THEN: The three platform functions should perform properly
358- self.assertTrue(is_macosx(), 'is_macosx() should return True')
359- self.assertFalse(is_win(), 'is_win() should return False')
360- self.assertFalse(is_linux(), 'is_linux() should return False')
361+ assert is_macosx(), 'is_macosx() should return True'
362+ assert is_win() is False, 'is_win() should return False'
363+ assert is_linux() is False, 'is_linux() should return False'
364
365 def test_is_linux(self):
366 """
367@@ -206,9 +207,9 @@
368 mocked_sys.platform = 'linux3'
369
370 # THEN: The three platform functions should perform properly
371- self.assertTrue(is_linux(), 'is_linux() should return True')
372- self.assertFalse(is_win(), 'is_win() should return False')
373- self.assertFalse(is_macosx(), 'is_macosx() should return False')
374+ assert is_linux(), 'is_linux() should return True'
375+ assert is_win() is False, 'is_win() should return False'
376+ assert is_macosx() is False, 'is_macosx() should return False'
377
378 def test_clean_button_text(self):
379 """
380@@ -222,4 +223,4 @@
381 actual_text = clean_button_text(input_text)
382
383 # THEN: The text should have been cleaned
384- self.assertEqual(expected_text, actual_text, 'The text should be clean')
385+ assert expected_text == actual_text, 'The text should be clean'
386
387=== modified file 'tests/functional/openlp_core/common/test_httputils.py'
388--- tests/functional/openlp_core/common/test_httputils.py 2017-11-03 20:55:41 +0000
389+++ tests/functional/openlp_core/common/test_httputils.py 2017-12-15 16:30:32 +0000
390@@ -59,7 +59,7 @@
391
392 # THEN: The user agent is a Linux (or ChromeOS) user agent
393 result = 'Linux' in user_agent or 'CrOS' in user_agent
394- self.assertTrue(result, 'The user agent should be a valid Linux user agent')
395+ assert result, 'The user agent should be a valid Linux user agent'
396
397 def test_get_user_agent_windows(self):
398 """
399@@ -74,7 +74,7 @@
400 user_agent = get_user_agent()
401
402 # THEN: The user agent is a Linux (or ChromeOS) user agent
403- self.assertIn('Windows', user_agent, 'The user agent should be a valid Windows user agent')
404+ assert 'Windows' in user_agent, 'The user agent should be a valid Windows user agent'
405
406 def test_get_user_agent_macos(self):
407 """
408@@ -89,7 +89,7 @@
409 user_agent = get_user_agent()
410
411 # THEN: The user agent is a Linux (or ChromeOS) user agent
412- self.assertIn('Mac OS X', user_agent, 'The user agent should be a valid OS X user agent')
413+ assert 'Mac OS X' in user_agent, 'The user agent should be a valid OS X user agent'
414
415 def test_get_user_agent_default(self):
416 """
417@@ -104,7 +104,7 @@
418 user_agent = get_user_agent()
419
420 # THEN: The user agent is a Linux (or ChromeOS) user agent
421- self.assertIn('NetBSD', user_agent, 'The user agent should be the default user agent')
422+ assert 'NetBSD'in user_agent, 'The user agent should be the default user agent'
423
424 def test_get_web_page_no_url(self):
425 """
426@@ -117,7 +117,7 @@
427 result = get_web_page(test_url)
428
429 # THEN: None should be returned
430- self.assertIsNone(result, 'The return value of get_web_page should be None')
431+ assert result is None, 'The return value of get_web_page should be None'
432
433 @patch('openlp.core.common.httputils.requests')
434 @patch('openlp.core.common.httputils.get_user_agent')
435@@ -240,4 +240,4 @@
436
437 # THEN: socket.timeout should have been caught
438 # NOTE: Test is if $tmpdir/tempfile is still there, then test fails since ftw deletes bad downloaded files
439- assert not os.path.exists(self.tempfile), 'tempfile should have been deleted'
440+ assert os.path.exists(self.tempfile) is False, 'tempfile should have been deleted'
441
442=== modified file 'tests/functional/openlp_core/common/test_init.py'
443--- tests/functional/openlp_core/common/test_init.py 2017-11-18 23:14:28 +0000
444+++ tests/functional/openlp_core/common/test_init.py 2017-12-15 16:30:32 +0000
445@@ -63,8 +63,8 @@
446 add_actions(mocked_target, empty_list)
447
448 # THEN: The add method on the mocked target is never called
449- self.assertEqual(0, mocked_target.addSeparator.call_count, 'addSeparator method should not have been called')
450- self.assertEqual(0, mocked_target.addAction.call_count, 'addAction method should not have been called')
451+ assert mocked_target.addSeparator.call_count == 0, 'addSeparator method should not have been called'
452+ assert mocked_target.addAction.call_count == 0, 'addAction method should not have been called'
453
454 def test_add_actions_none_action(self):
455 """
456@@ -79,7 +79,7 @@
457
458 # THEN: The addSeparator method is called, but the addAction method is never called
459 mocked_target.addSeparator.assert_called_with()
460- self.assertEqual(0, mocked_target.addAction.call_count, 'addAction method should not have been called')
461+ assert mocked_target.addAction.call_count == 0, 'addAction method should not have been called'
462
463 def test_add_actions_add_action(self):
464 """
465@@ -93,7 +93,7 @@
466 add_actions(mocked_target, action_list)
467
468 # THEN: The addSeparator method is not called, and the addAction method is called
469- self.assertEqual(0, mocked_target.addSeparator.call_count, 'addSeparator method should not have been called')
470+ assert mocked_target.addSeparator.call_count == 0, 'addSeparator method should not have been called'
471 mocked_target.addAction.assert_called_with('action')
472
473 def test_add_actions_action_and_none(self):
474@@ -150,9 +150,8 @@
475 result = get_uno_command()
476
477 # THEN: The command 'libreoffice' should be called with the appropriate parameters
478- self.assertEquals(result,
479- 'libreoffice --nologo --norestore --minimized --nodefault --nofirststartwizard'
480- ' "--accept=pipe,name=openlp_pipe;urp;"')
481+ assert result == 'libreoffice --nologo --norestore --minimized --nodefault --nofirststartwizard' \
482+ ' "--accept=pipe,name=openlp_pipe;urp;"'
483
484 def test_get_uno_command_only_soffice_command_exists(self):
485 """
486@@ -169,8 +168,8 @@
487 result = get_uno_command()
488
489 # THEN: The command 'soffice' should be called with the appropriate parameters
490- self.assertEquals(result, 'soffice --nologo --norestore --minimized --nodefault --nofirststartwizard'
491- ' "--accept=pipe,name=openlp_pipe;urp;"')
492+ assert result == 'soffice --nologo --norestore --minimized --nodefault --nofirststartwizard' \
493+ ' "--accept=pipe,name=openlp_pipe;urp;"'
494
495 def test_get_uno_command_when_no_command_exists(self):
496 """
497@@ -198,8 +197,8 @@
498 result = get_uno_command('socket')
499
500 # THEN: The connection parameters should be set for socket
501- self.assertEqual(result, 'libreoffice --nologo --norestore --minimized --nodefault --nofirststartwizard'
502- ' "--accept=socket,host=localhost,port=2002;urp;"')
503+ assert result == 'libreoffice --nologo --norestore --minimized --nodefault --nofirststartwizard' \
504+ ' "--accept=socket,host=localhost,port=2002;urp;"'
505
506 def test_get_filesystem_encoding_sys_function_not_called(self):
507 """
508@@ -215,8 +214,8 @@
509
510 # THEN: getdefaultencoding should have been called
511 mocked_getfilesystemencoding.assert_called_with()
512- self.assertEqual(0, mocked_getdefaultencoding.called, 'getdefaultencoding should not have been called')
513- self.assertEqual('cp1252', result, 'The result should be "cp1252"')
514+ assert mocked_getdefaultencoding.called == 0, 'getdefaultencoding should not have been called'
515+ assert 'cp1252' == result, 'The result should be "cp1252"'
516
517 def test_get_filesystem_encoding_sys_function_is_called(self):
518 """
519@@ -234,7 +233,7 @@
520 # THEN: getdefaultencoding should have been called
521 mocked_getfilesystemencoding.assert_called_with()
522 mocked_getdefaultencoding.assert_called_with()
523- self.assertEqual('utf-8', result, 'The result should be "utf-8"')
524+ assert 'utf-8' == result, 'The result should be "utf-8"'
525
526 def test_clean_filename(self):
527 """
528@@ -248,7 +247,7 @@
529 result = clean_filename(invalid_name)
530
531 # THEN: The file name should be cleaned.
532- self.assertEqual(wanted_name, result, 'The file name should not contain any special characters.')
533+ assert wanted_name == result, 'The file name should not contain any special characters.'
534
535 def test_delete_file_no_path(self):
536 """
537@@ -259,7 +258,7 @@
538 result = delete_file(None)
539
540 # THEN: delete_file should return False
541- self.assertFalse(result, "delete_file should return False when called with None")
542+ assert result is False, "delete_file should return False when called with None"
543
544 def test_delete_file_path_success(self):
545 """
546@@ -272,7 +271,7 @@
547 result = delete_file(Path('path', 'file.ext'))
548
549 # THEN: delete_file should return True
550- self.assertTrue(result, 'delete_file should return True when it successfully deletes a file')
551+ assert result is True, 'delete_file should return True when it successfully deletes a file'
552
553 def test_delete_file_path_no_file_exists(self):
554 """
555@@ -286,8 +285,8 @@
556 result = delete_file(Path('path', 'file.ext'))
557
558 # THEN: The function should not attempt to delete the file and it should return True
559- self.assertFalse(mocked_unlink.called)
560- self.assertTrue(result, 'delete_file should return True when the file doesnt exist')
561+ assert mocked_unlink.called is False
562+ assert result, 'delete_file should return True when the file doesnt exist'
563
564 def test_delete_file_path_exception(self):
565 """
566@@ -303,8 +302,8 @@
567 result = delete_file(Path('path', 'file.ext'))
568
569 # THEN: The exception should be logged and `delete_file` should return False
570- self.assertTrue(mocked_log.exception.called)
571- self.assertFalse(result, 'delete_file should return False when an OSError is raised')
572+ assert mocked_log.exception.called
573+ assert result is False, 'delete_file should return False when an OSError is raised'
574
575 def test_get_file_encoding_done(self):
576 """
577@@ -323,9 +322,9 @@
578
579 # THEN: The feed method of UniversalDetector should only br called once before returning a result
580 mocked_open.assert_called_once_with('rb')
581- self.assertEqual(mocked_universal_detector_inst.feed.mock_calls, [call(b"data" * 256)])
582+ assert mocked_universal_detector_inst.feed.mock_calls == [call(b"data" * 256)]
583 mocked_universal_detector_inst.close.assert_called_once_with()
584- self.assertEqual(result, encoding_result)
585+ assert result == encoding_result
586
587 def test_get_file_encoding_eof(self):
588 """
589@@ -345,9 +344,9 @@
590
591 # THEN: The feed method of UniversalDetector should have been called twice before returning a result
592 mocked_open.assert_called_once_with('rb')
593- self.assertEqual(mocked_universal_detector_inst.feed.mock_calls, [call(b"data" * 256), call(b"data" * 4)])
594+ assert mocked_universal_detector_inst.feed.mock_calls == [call(b"data" * 256), call(b"data" * 4)]
595 mocked_universal_detector_inst.close.assert_called_once_with()
596- self.assertEqual(result, encoding_result)
597+ assert result, encoding_result
598
599 def test_get_file_encoding_oserror(self):
600 """
601@@ -364,4 +363,4 @@
602
603 # THEN: log.exception should be called and get_file_encoding should return None
604 mocked_log.exception.assert_called_once_with('Error detecting file encoding')
605- self.assertIsNone(result)
606+ assert result is None
607
608=== modified file 'tests/functional/openlp_core/common/test_json.py'
609--- tests/functional/openlp_core/common/test_json.py 2017-08-25 20:03:25 +0000
610+++ tests/functional/openlp_core/common/test_json.py 2017-12-15 16:30:32 +0000
611@@ -45,7 +45,7 @@
612 result = instance.object_hook({'__Path__': ['test', 'path']})
613
614 # THEN: A Path object should be returned
615- self.assertEqual(result, Path('test', 'path'))
616+ assert result == Path('test', 'path')
617
618 def test_object_hook_non_path_object(self):
619 """
620@@ -59,8 +59,8 @@
621 result = instance.object_hook({'key': 'value'})
622
623 # THEN: The object should be returned unchanged and a Path object should not have been initiated
624- self.assertEqual(result, {'key': 'value'})
625- self.assertFalse(mocked_path.called)
626+ assert result == {'key': 'value'}
627+ assert mocked_path.called is False
628
629 def test_json_decode(self):
630 """
631@@ -73,7 +73,7 @@
632 obj = json.loads(json_string, cls=OpenLPJsonDecoder)
633
634 # THEN: The object returned should be a python version of the JSON string
635- self.assertEqual(obj, [Path('test', 'path1'), Path('test', 'path2')])
636+ assert obj == [Path('test', 'path1'), Path('test', 'path2')]
637
638
639 class TestOpenLPJsonEncoder(TestCase):
640@@ -91,7 +91,7 @@
641 result = instance.default(Path('test', 'path'))
642
643 # THEN: A dictionary object that can be JSON encoded should be returned
644- self.assertEqual(result, {'__Path__': ('test', 'path')})
645+ assert result == {'__Path__': ('test', 'path')}
646
647 def test_default_non_path_object(self):
648 """
649@@ -119,4 +119,4 @@
650 json_string = json.dumps(obj, cls=OpenLPJsonEncoder)
651
652 # THEN: The JSON string return should be a representation of the object encoded
653- self.assertEqual(json_string, '[{"__Path__": ["test", "path1"]}, {"__Path__": ["test", "path2"]}]')
654+ assert json_string == '[{"__Path__": ["test", "path1"]}, {"__Path__": ["test", "path2"]}]'
655
656=== modified file 'tests/functional/openlp_core/common/test_mixins.py'
657--- tests/functional/openlp_core/common/test_mixins.py 2017-10-23 22:09:57 +0000
658+++ tests/functional/openlp_core/common/test_mixins.py 2017-12-15 16:30:32 +0000
659@@ -46,7 +46,7 @@
660 # GIVEN an Empty Registry
661 # WHEN there is no Application
662 # THEN the application should be none
663- self.assertEqual(self.application, None, 'The application value should be None')
664+ assert self.application is None, 'The application value should be None'
665
666 def test_application(self):
667 """
668@@ -59,7 +59,7 @@
669 Registry().register('application', application)
670
671 # THEN the application should be none
672- self.assertEqual(self.application, application, 'The application value should match')
673+ assert self.application == application, 'The application value should match'
674
675 @patch('openlp.core.common.mixins.is_win')
676 def test_application_on_windows(self, mocked_is_win):
677@@ -74,7 +74,7 @@
678 Registry().register('application', application)
679
680 # THEN the application should be none
681- self.assertEqual(self.application, application, 'The application value should match')
682+ assert self.application == application, 'The application value should match'
683
684 @patch('openlp.core.common.mixins.is_win')
685 def test_get_application_on_windows(self, mocked_is_win):
686@@ -93,6 +93,6 @@
687 actual_application = reg_props.application
688
689 # THEN the application should be the mock object, and the correct function should have been called
690- self.assertEqual(mock_application, actual_application, 'The application value should match')
691+ assert mock_application == actual_application, 'The application value should match'
692 mocked_is_win.assert_called_with()
693 mocked_get.assert_called_with('application')
694
695=== modified file 'tests/functional/openlp_core/common/test_path.py'
696--- tests/functional/openlp_core/common/test_path.py 2017-11-20 21:57:34 +0000
697+++ tests/functional/openlp_core/common/test_path.py 2017-12-15 16:30:32 +0000
698@@ -47,8 +47,8 @@
699 result_args, result_kwargs = replace_params(test_args, test_kwargs, test_params)
700
701 # THEN: The positional and keyword args should not have changed
702- self.assertEqual(test_args, result_args)
703- self.assertEqual(test_kwargs, result_kwargs)
704+ assert test_args == result_args
705+ assert test_kwargs == result_kwargs
706
707 def test_replace_params_params(self):
708 """
709@@ -63,8 +63,8 @@
710 result_args, result_kwargs = replace_params(test_args, test_kwargs, test_params)
711
712 # THEN: The positional and keyword args should have have changed
713- self.assertEqual(result_args, (1, '2'))
714- self.assertEqual(result_kwargs, {'arg3': '3', 'arg4': 4})
715+ assert result_args == (1, '2')
716+ assert result_kwargs == {'arg3': '3', 'arg4': 4}
717
718 def test_copy(self):
719 """
720@@ -82,7 +82,7 @@
721 # :func:`shutil.copy` as a Path object.
722 mocked_shutil_copy.assert_called_once_with(os.path.join('source', 'test', 'path'),
723 os.path.join('destination', 'test', 'path'))
724- self.assertEqual(result, Path('destination', 'test', 'path'))
725+ assert result == Path('destination', 'test', 'path')
726
727 def test_copy_follow_optional_params(self):
728 """
729@@ -114,7 +114,7 @@
730 # :func:`shutil.copyfile` as a Path object.
731 mocked_shutil_copyfile.assert_called_once_with(os.path.join('source', 'test', 'path'),
732 os.path.join('destination', 'test', 'path'))
733- self.assertEqual(result, Path('destination', 'test', 'path'))
734+ assert result == Path('destination', 'test', 'path')
735
736 def test_copyfile_optional_params(self):
737 """
738@@ -147,7 +147,7 @@
739 # :func:`shutil.copytree` as a Path object.
740 mocked_shutil_copytree.assert_called_once_with(os.path.join('source', 'test', 'path'),
741 os.path.join('destination', 'test', 'path'))
742- self.assertEqual(result, Path('destination', 'test', 'path'))
743+ assert result == Path('destination', 'test', 'path')
744
745 def test_copytree_optional_params(self):
746 """
747@@ -177,12 +177,11 @@
748 path = Path('test', 'path')
749
750 # WHEN: Calling :func:`openlp.core.common.path.rmtree` with the path parameter as Path object type
751- result = path.rmtree()
752+ path.rmtree()
753
754 # THEN: :func:`shutil.rmtree` should have been called with the str equivalents of the Path object.
755 mocked_shutil_rmtree.assert_called_once_with(
756 os.path.join('test', 'path'), False, None)
757- self.assertIsNone(result)
758
759 def test_rmtree_optional_params(self):
760 """
761@@ -214,7 +213,7 @@
762
763 # THEN: :func:`shutil.which` should have been called with the command, and :func:`which` should return None.
764 mocked_shutil_which.assert_called_once_with('no_command')
765- self.assertIsNone(result)
766+ assert result is None
767
768 def test_which_command(self):
769 """
770@@ -230,7 +229,7 @@
771 # THEN: :func:`shutil.which` should have been called with the command, and :func:`which` should return a
772 # Path object equivalent of the command path.
773 mocked_shutil_which.assert_called_once_with('command')
774- self.assertEqual(result, Path('path', 'to', 'command'))
775+ assert result == Path('path', 'to', 'command')
776
777
778 class TestPath(TestCase):
779@@ -257,7 +256,7 @@
780 result = path_to_str(None)
781
782 # THEN: `path_to_str` should return an empty string
783- self.assertEqual(result, '')
784+ assert result == ''
785
786 def test_path_to_str_path_object(self):
787 """
788@@ -268,7 +267,7 @@
789 result = path_to_str(Path('test/path'))
790
791 # THEN: `path_to_str` should return a string representation of the Path object
792- self.assertEqual(result, os.path.join('test', 'path'))
793+ assert result == os.path.join('test', 'path')
794
795 def test_str_to_path_type_error(self):
796 """
797@@ -289,7 +288,7 @@
798 result = str_to_path('')
799
800 # THEN: `path_to_str` should return None
801- self.assertEqual(result, None)
802+ assert result is None
803
804 def test_path_encode_json(self):
805 """
806@@ -301,7 +300,7 @@
807 path = Path.encode_json({'__Path__': ['path', 'to', 'fi.le']}, extra=1, args=2)
808
809 # THEN: A Path object should have been returned
810- self.assertEqual(path, Path('path', 'to', 'fi.le'))
811+ assert path == Path('path', 'to', 'fi.le')
812
813 def test_path_encode_json_base_path(self):
814 """
815@@ -313,7 +312,7 @@
816 path = Path.encode_json({'__Path__': ['path', 'to', 'fi.le']}, base_path=Path('/base'))
817
818 # THEN: A Path object should have been returned with an absolute path
819- self.assertEqual(path, Path('/', 'base', 'path', 'to', 'fi.le'))
820+ assert path == Path('/', 'base', 'path', 'to', 'fi.le')
821
822 def test_path_json_object(self):
823 """
824@@ -326,7 +325,7 @@
825 obj = path.json_object(extra=1, args=2)
826
827 # THEN: A JSON decodable object should have been returned.
828- self.assertEqual(obj, {'__Path__': ('/', 'base', 'path', 'to', 'fi.le')})
829+ assert obj == {'__Path__': ('/', 'base', 'path', 'to', 'fi.le')}
830
831 def test_path_json_object_base_path(self):
832 """
833@@ -340,7 +339,7 @@
834 obj = path.json_object(base_path=Path('/', 'base'))
835
836 # THEN: A JSON decodable object should have been returned.
837- self.assertEqual(obj, {'__Path__': ('path', 'to', 'fi.le')})
838+ assert obj == {'__Path__': ('path', 'to', 'fi.le')}
839
840 def test_create_paths_dir_exists(self):
841 """
842
843=== modified file 'tests/functional/openlp_core/common/test_projector_utilities.py'
844--- tests/functional/openlp_core/common/test_projector_utilities.py 2016-12-31 11:01:36 +0000
845+++ tests/functional/openlp_core/common/test_projector_utilities.py 2017-12-15 16:30:32 +0000
846@@ -45,7 +45,7 @@
847 ip6_bad = 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
848
849
850-class testProjectorUtilities(TestCase):
851+class TestProjectorUtilities(TestCase):
852 """
853 Validate functions in the projector utilities module
854 """
855@@ -57,7 +57,7 @@
856 valid = verify_ip_address(addr=ip4_loopback)
857
858 # THEN: Verify we received True
859- self.assertTrue(valid, 'IPv4 loopback address should have been valid')
860+ assert valid, 'IPv4 loopback address should have been valid'
861
862 def test_ip4_local_valid(self):
863 """
864@@ -67,7 +67,7 @@
865 valid = verify_ip_address(addr=ip4_local)
866
867 # THEN: Verify we received True
868- self.assertTrue(valid, 'IPv4 local address should have been valid')
869+ assert valid, 'IPv4 local address should have been valid'
870
871 def test_ip4_broadcast_valid(self):
872 """
873@@ -77,7 +77,7 @@
874 valid = verify_ip_address(addr=ip4_broadcast)
875
876 # THEN: Verify we received True
877- self.assertTrue(valid, 'IPv4 broadcast address should have been valid')
878+ assert valid, 'IPv4 broadcast address should have been valid'
879
880 def test_ip4_address_invalid(self):
881 """
882@@ -87,7 +87,7 @@
883 valid = verify_ip_address(addr=ip4_bad)
884
885 # THEN: Verify we received True
886- self.assertFalse(valid, 'Bad IPv4 address should not have been valid')
887+ assert valid is False, 'Bad IPv4 address should not have been valid'
888
889 def test_ip6_loopback_valid(self):
890 """
891@@ -97,7 +97,7 @@
892 valid = verify_ip_address(addr=ip6_loopback)
893
894 # THEN: Validate return
895- self.assertTrue(valid, 'IPv6 loopback address should have been valid')
896+ assert valid, 'IPv6 loopback address should have been valid'
897
898 def test_ip6_local_valid(self):
899 """
900@@ -107,7 +107,7 @@
901 valid = verify_ip_address(addr=ip6_link_local)
902
903 # THEN: Validate return
904- self.assertTrue(valid, 'IPv6 link-local address should have been valid')
905+ assert valid, 'IPv6 link-local address should have been valid'
906
907 def test_ip6_address_invalid(self):
908 """
909@@ -117,7 +117,7 @@
910 valid = verify_ip_address(addr=ip6_bad)
911
912 # THEN: Validate bad return
913- self.assertFalse(valid, 'IPv6 bad address should have been invalid')
914+ assert valid is False, 'IPv6 bad address should have been invalid'
915
916 def test_md5_hash(self):
917 """
918@@ -127,7 +127,7 @@
919 hash_ = md5_hash(salt=salt.encode('utf-8'), data=pin.encode('utf-8'))
920
921 # THEN: Validate return has is same
922- self.assertEquals(hash_, test_hash, 'MD5 should have returned a good hash')
923+ assert hash_ == test_hash, 'MD5 should have returned a good hash'
924
925 def test_md5_hash_bad(self):
926 """
927@@ -137,7 +137,7 @@
928 hash_ = md5_hash(salt=pin.encode('utf-8'), data=salt.encode('utf-8'))
929
930 # THEN: return data is different
931- self.assertNotEquals(hash_, test_hash, 'MD5 should have returned a bad hash')
932+ assert hash_ is not test_hash, 'MD5 should have returned a bad hash'
933
934 def test_qmd5_hash(self):
935 """
936@@ -147,7 +147,7 @@
937 hash_ = qmd5_hash(salt=salt.encode('utf-8'), data=pin.encode('utf-8'))
938
939 # THEN: Validate return has is same
940- self.assertEquals(hash_, test_hash, 'Qt-MD5 should have returned a good hash')
941+ assert hash_ == test_hash, 'Qt-MD5 should have returned a good hash'
942
943 def test_qmd5_hash_bad(self):
944 """
945@@ -157,7 +157,7 @@
946 hash_ = qmd5_hash(salt=pin.encode('utf-8'), data=salt.encode('utf-8'))
947
948 # THEN: return data is different
949- self.assertNotEquals(hash_, test_hash, 'Qt-MD5 should have returned a bad hash')
950+ assert hash_ is not test_hash, 'Qt-MD5 should have returned a bad hash'
951
952 def test_md5_non_ascii_string(self):
953 """
954@@ -167,7 +167,7 @@
955 hash_ = md5_hash(salt=test_non_ascii_string.encode('utf-8'), data=None)
956
957 # THEN: Valid MD5 hash should be returned
958- self.assertEqual(hash_, test_non_ascii_hash, 'MD5 should have returned a valid hash')
959+ assert hash_ == test_non_ascii_hash, 'MD5 should have returned a valid hash'
960
961 def test_qmd5_non_ascii_string(self):
962 """
963@@ -177,4 +177,4 @@
964 hash_ = md5_hash(data=test_non_ascii_string.encode('utf-8'))
965
966 # THEN: Valid MD5 hash should be returned
967- self.assertEqual(hash_, test_non_ascii_hash, 'Qt-MD5 should have returned a valid hash')
968+ assert hash_ == test_non_ascii_hash, 'Qt-MD5 should have returned a valid hash'
969
970=== modified file 'tests/functional/openlp_core/common/test_registry.py'
971--- tests/functional/openlp_core/common/test_registry.py 2017-10-23 22:09:57 +0000
972+++ tests/functional/openlp_core/common/test_registry.py 2017-12-15 16:30:32 +0000
973@@ -51,19 +51,19 @@
974 # THEN and I will get an exception
975 with self.assertRaises(KeyError) as context:
976 Registry().register('test1', mock_1)
977- self.assertEqual(context.exception.args[0], 'Duplicate service exception test1',
978- 'KeyError exception should have been thrown for duplicate service')
979+ assert context.exception.args[0] == 'Duplicate service exception test1', \
980+ 'KeyError exception should have been thrown for duplicate service'
981
982 # WHEN I try to get back a non existent component
983 # THEN I will get an exception
984 temp = Registry().get('test2')
985- self.assertEqual(temp, None, 'None should have been returned for missing service')
986+ assert temp is None, 'None should have been returned for missing service'
987
988 # WHEN I try to replace a component I should be allowed
989 Registry().remove('test1')
990 # THEN I will get an exception
991 temp = Registry().get('test1')
992- self.assertEqual(temp, None, 'None should have been returned for deleted service')
993+ assert temp is None, 'None should have been returned for deleted service'
994
995 def test_registry_function(self):
996 """
997@@ -77,21 +77,21 @@
998 return_value = Registry().execute('test1')
999
1000 # THEN: I expect then function to have been called and a return given
1001- self.assertEqual(return_value[0], 'function_1', 'A return value is provided and matches')
1002+ assert return_value[0] == 'function_1', 'A return value is provided and matches'
1003
1004 # WHEN: I execute the a function with the same reference and execute the function
1005 Registry().register_function('test1', self.dummy_function_1)
1006 return_value = Registry().execute('test1')
1007
1008 # THEN: I expect then function to have been called and a return given
1009- self.assertEqual(return_value, ['function_1', 'function_1'], 'A return value list is provided and matches')
1010+ assert return_value == ['function_1', 'function_1'], 'A return value list is provided and matches'
1011
1012 # WHEN: I execute the a 2nd function with the different reference and execute the function
1013 Registry().register_function('test2', self.dummy_function_2)
1014 return_value = Registry().execute('test2')
1015
1016 # THEN: I expect then function to have been called and a return given
1017- self.assertEqual(return_value[0], 'function_2', 'A return value is provided and matches')
1018+ assert return_value[0] == 'function_2', 'A return value is provided and matches'
1019
1020 def test_registry_working_flags(self):
1021 """
1022@@ -107,28 +107,28 @@
1023
1024 # THEN: we should be able retrieve the saved component
1025 temp = Registry().get_flag('test1')
1026- self.assertEquals(temp, my_data, 'The value should have been saved')
1027+ assert temp == my_data, 'The value should have been saved'
1028
1029 # WHEN: I add a component for the second time I am not mad.
1030 # THEN and I will not get an exception
1031 Registry().set_flag('test1', my_data2)
1032 temp = Registry().get_flag('test1')
1033- self.assertEquals(temp, my_data2, 'The value should have been updated')
1034+ assert temp == my_data2, 'The value should have been updated'
1035
1036 # WHEN I try to get back a non existent Working Flag
1037 # THEN I will get an exception
1038 with self.assertRaises(KeyError) as context1:
1039 temp = Registry().get_flag('test2')
1040- self.assertEqual(context1.exception.args[0], 'Working Flag test2 not found in list',
1041- 'KeyError exception should have been thrown for missing working flag')
1042+ assert context1.exception.args[0] == 'Working Flag test2 not found in list', \
1043+ 'KeyError exception should have been thrown for missing working flag'
1044
1045 # WHEN I try to replace a working flag I should be allowed
1046 Registry().remove_flag('test1')
1047 # THEN I will get an exception
1048 with self.assertRaises(KeyError) as context:
1049 temp = Registry().get_flag('test1')
1050- self.assertEqual(context.exception.args[0], 'Working Flag test1 not found in list',
1051- 'KeyError exception should have been thrown for duplicate working flag')
1052+ assert context.exception.args[0] == 'Working Flag test1 not found in list', \
1053+ 'KeyError exception should have been thrown for duplicate working flag'
1054
1055 def test_remove_function(self):
1056 """
1057@@ -142,7 +142,7 @@
1058 Registry().remove_function('test1', self.dummy_function_1)
1059
1060 # THEN: The method should not be available.
1061- assert not Registry().functions_list['test1'], 'The function should not be in the dict anymore.'
1062+ assert Registry().functions_list['test1'] == [], 'The function should not be in the dict anymore.'
1063
1064 def dummy_function_1(self):
1065 return "function_1"
1066@@ -174,7 +174,7 @@
1067 PlainStub()
1068
1069 # THEN: Nothing is registered with the registry
1070- self.assertEqual(len(Registry().functions_list), 0), 'The function should not be in the dict anymore.'
1071+ assert len(Registry().functions_list) == 0, 'The function should not be in the dict anymore.'
1072
1073 def test_registry_mixin_present(self):
1074 """
1075@@ -187,4 +187,4 @@
1076 RegistryStub()
1077
1078 # THEN: The bootstrap methods should be registered
1079- self.assertEqual(len(Registry().functions_list), 2), 'The bootstrap functions should be in the dict.'
1080+ assert len(Registry().functions_list) == 2, 'The bootstrap functions should be in the dict.'
1081
1082=== modified file 'tests/functional/openlp_core/common/test_settings.py'
1083--- tests/functional/openlp_core/common/test_settings.py 2017-11-16 05:03:19 +0000
1084+++ tests/functional/openlp_core/common/test_settings.py 2017-12-15 16:30:32 +0000
1085@@ -139,13 +139,13 @@
1086 extend = settings.value('extend')
1087
1088 # THEN the default value is returned
1089- self.assertEqual('very wide', extend, 'The default value defined should be returned')
1090+ assert 'very wide' == extend, 'The default value defined should be returned'
1091
1092 # WHEN a new value is saved into config
1093 Settings().setValue('test/extend', 'very short')
1094
1095 # THEN the new value is returned when re-read
1096- self.assertEqual('very short', Settings().value('test/extend'), 'The saved value should be returned')
1097+ assert 'very short' == Settings().value('test/extend'), 'The saved value should be returned'
1098
1099 def test_settings_nonexisting(self):
1100 """Test the Settings on query for non-existing value"""
1101@@ -155,7 +155,7 @@
1102 Settings().value('core/does not exists')
1103
1104 # THEN: An exception with the non-existing key should be thrown
1105- self.assertEqual(str(cm.exception), "'core/does not exists'", 'We should get an exception')
1106+ assert str(cm.exception) == "'core/does not exists'", 'We should get an exception'
1107
1108 def test_extend_default_settings(self):
1109 """Test that the extend_default_settings method extends the default settings"""
1110@@ -167,9 +167,8 @@
1111 Settings.extend_default_settings({'test/setting 3': 4, 'test/extended 1': 1, 'test/extended 2': 2})
1112
1113 # THEN: The _default_settings__ dictionary_ should have the new keys
1114- self.assertEqual(
1115- Settings.__default_settings__, {'test/setting 1': 1, 'test/setting 2': 2, 'test/setting 3': 4,
1116- 'test/extended 1': 1, 'test/extended 2': 2})
1117+ assert Settings.__default_settings__ == {'test/setting 1': 1, 'test/setting 2': 2, 'test/setting 3': 4,
1118+ 'test/extended 1': 1, 'test/extended 2': 2}
1119
1120 @patch('openlp.core.common.settings.QtCore.QSettings.contains')
1121 @patch('openlp.core.common.settings.QtCore.QSettings.value')
1122
1123=== modified file 'tests/functional/openlp_core/ui/test_mainwindow.py'
1124--- tests/functional/openlp_core/ui/test_mainwindow.py 2017-12-02 09:37:55 +0000
1125+++ tests/functional/openlp_core/ui/test_mainwindow.py 2017-12-15 16:30:32 +0000
1126@@ -106,7 +106,7 @@
1127 self.main_window.open_cmd_line_files("")
1128
1129 # THEN the file should not be opened
1130- assert not mocked_load_file.called, 'load_file should not have been called'
1131+ assert mocked_load_file.called is False, 'load_file should not have been called'
1132
1133 def test_main_window_title(self):
1134 """