Skip to content

Commit a41f10c

Browse files
committed
Reordered test assertions
Signed-off-by: Aditya Viki <[email protected]> Signed-off-by: adityaviki <[email protected]>
1 parent 5174a3b commit a41f10c

Some content is hidden

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

55 files changed

+896
-901
lines changed

tests/cluecode/cluecode_test_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def closure_test_function(*args, **kwargs):
216216
'\ntest file: file://' + test_file + '\n'
217217
) + expected_yaml
218218

219-
assert expected_yaml == results_yaml
219+
assert results_yaml == expected_yaml
220220

221221
data_file = test.data_file
222222
test_file = test.test_file

tests/cluecode/test_copyrights_basic.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -20,51 +20,51 @@ class TestTextPreparation(FileBasedTesting):
2020

2121
def test_strip_leading_numbers(self):
2222
a = '2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32'
23-
assert a == copyrights_module.strip_leading_numbers(a)
23+
assert copyrights_module.strip_leading_numbers(a) == a
2424

2525
a = '26 6 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on 12'
2626
expected = '2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on 12'
27-
assert expected == copyrights_module.strip_leading_numbers(a)
27+
assert copyrights_module.strip_leading_numbers(a) == expected
2828

2929
def test_prepare_text_line(self):
3030
cp = 'test (C) all rights reserved'
3131
result = copyrights_module.prepare_text_line(cp)
32-
assert 'test (c) all rights reserved' == result
32+
assert result == 'test (c) all rights reserved'
3333

3434
def test_prepare_text_line_debian(self):
3535
cp = 'Parts Copyright (c) 1992 <s>Uri Blumentha<s>l, I</s>BM</s>'
3636
result = copyrights_module.prepare_text_line(cp)
37-
assert 'Parts Copyright (c) 1992 Uri Blumenthal, IBM' == result
37+
assert result == 'Parts Copyright (c) 1992 Uri Blumenthal, IBM'
3838

3939
def test_prepare_text_line_does_not_truncate_transliterable_unicode(self):
4040
cp = u'Muła'
4141
result = copyrights_module.prepare_text_line(cp)
42-
assert 'Mula' == result
42+
assert result == 'Mula'
4343

4444
def test_strip_markup(self):
4545
cp = 'Parts Copyright (c) 1992 <s>Uri Blumentha<s>l, I</s>BM</s>'
4646
result = copyrights_module.strip_markup(cp)
47-
assert 'Parts Copyright (c) 1992 Uri Blumenthal, IBM' == result
47+
assert result == 'Parts Copyright (c) 1992 Uri Blumenthal, IBM'
4848

4949
def test_prepare_text_line_removes_C_comments(self):
5050
cp = '/* Copyright 1996-2005, 2008-2011 by */'
5151
result = copyrights_module.prepare_text_line(cp)
52-
assert 'Copyright 1996-2005, 2008-2011 by' == result
52+
assert result == 'Copyright 1996-2005, 2008-2011 by'
5353

5454
def test_prepare_text_line_removes_C_comments2(self):
5555
cp = '/* David Turner, Robert Wilhelm, and Werner Lemberg. */'
5656
result = copyrights_module.prepare_text_line(cp)
57-
assert 'David Turner, Robert Wilhelm, and Werner Lemberg.' == result
57+
assert result == 'David Turner, Robert Wilhelm, and Werner Lemberg.'
5858

5959
def test_prepare_text_line_removes_Cpp_comments(self):
6060
cp = '// David Turner, Robert Wilhelm, and Werner Lemberg. */'
6161
result = copyrights_module.prepare_text_line(cp)
62-
assert 'David Turner, Robert Wilhelm, and Werner Lemberg.' == result
62+
assert result == 'David Turner, Robert Wilhelm, and Werner Lemberg.'
6363

6464
def test_prepare_text_line_does_not_damage_urls(self):
6565
cp = 'copyright (c) 2000 World Wide Web Consortium, http://www.w3.org'
6666
result = copyrights_module.prepare_text_line(cp)
67-
assert 'copyright (c) 2000 World Wide Web Consortium, http://www.w3.org' == result
67+
assert result == 'copyright (c) 2000 World Wide Web Consortium, http://www.w3.org'
6868

6969
def test_is_end_of_statement(self):
7070
line = ''' "All rights reserved\\n"'''
@@ -75,7 +75,7 @@ def test_candidate_lines_simple(self):
7575
lines = [(1, ' test (C) all rights reserved')]
7676
result = list(copyrights_module.candidate_lines(lines))
7777
expected = [[(1, ' test (C) all rights reserved')]]
78-
assert expected == result
78+
assert result == expected
7979

8080
def test_candidate_lines_complex(self):
8181
lines = '''
@@ -119,7 +119,7 @@ def test_candidate_lines_complex(self):
119119
]
120120

121121
result = list(copyrights_module.candidate_lines(enumerate(lines, 1)))
122-
assert expected == result
122+
assert result == expected
123123

124124
def test_is_candidates_should_not_select_line_with_bare_full_year(self):
125125
line = '2012'
@@ -204,7 +204,7 @@ def test_detect(self):
204204
'(c) 2008',
205205
]
206206
copyrights, _, _ = cluecode_test_utils.copyright_detector(location)
207-
assert expected == copyrights
207+
assert copyrights == expected
208208

209209
def test_detect_with_lines(self):
210210
location = self.get_test_loc('copyrights_basic/essential_smoke-ibm_c.c')
@@ -216,7 +216,7 @@ def test_detect_with_lines(self):
216216
('copyrights', u'(c) 2008', 8, 8)
217217
]
218218
results = list(copyrights_module.detect_copyrights(location))
219-
assert expected == results
219+
assert results == expected
220220

221221
def test_detect_with_lines_only_holders(self):
222222
location = self.get_test_loc('copyrights_basic/essential_smoke-ibm_c.c')
@@ -225,7 +225,7 @@ def test_detect_with_lines_only_holders(self):
225225
('holders', u'Eclipse, IBM and others', 8, 8)
226226
]
227227
results = list(copyrights_module.detect_copyrights(location, copyrights=False, authors=False))
228-
assert expected == results
228+
assert results == expected
229229

230230

231231
def check_detection_with_lines(expected, test_file):
@@ -241,7 +241,7 @@ def check_detection_with_lines(expected, test_file):
241241
)
242242

243243
results = [(statement, start, end) for _t, statement, start, end in detections]
244-
assert expected == results
244+
assert results == expected
245245

246246

247247
class TestCopyrightLinesDetection(FileBasedTesting):

tests/cluecode/test_copyrights_fosso.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def build_copyright_test_methods_with_fossology_data():
5454
expected_files.append(tf)
5555
files_to_test.append(tf.replace('_raw', ''))
5656

57-
assert sorted(test_files) == sorted(files_to_test + expected_files)
57+
assert sorted(files_to_test + expected_files) == sorted(test_files)
5858

5959
copyregex = re.compile('<s>(.*?)</s>', re.DOTALL | re.UNICODE) # NOQA
6060
for expected_file, test_file in zip(expected_files, files_to_test):
@@ -132,14 +132,14 @@ def copyright_test_method(self):
132132
copyrights, _authors, _holders = cluecode_test_utils.copyright_detector(test_file_loc)
133133

134134
try:
135-
assert expected == copyrights
135+
assert copyrights == expected
136136
except:
137137
failure_trace = [
138138
'Failed to detect copyright in: file://' + test_file_loc, '\n',
139139
'expected as file://' + expected_file_loc, '\n',
140140
] + expected
141141

142-
assert failure_trace == copyrights
142+
assert copyrights == failure_trace
143143

144144
return copyright_test_method
145145

0 commit comments

Comments
 (0)