1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-24 17:16:12 +01:00

- refactor assertEqualMultiline into common.py for reuse

This will be reused by the tests for the imminent prdiff subcommand.
This commit is contained in:
Adam Spiers 2013-01-18 19:38:25 +00:00
parent 33f3ab4203
commit 9b1c6f0204
2 changed files with 11 additions and 9 deletions

View File

@ -157,3 +157,13 @@ class OscTestCase(unittest.TestCase):
continue
self.assertTrue(os.path.exists(os.path.join('.osc', i.get('name'))))
self.assertEqual(osc.core.dgst(os.path.join('.osc', i.get('name'))), i.get('md5'))
def assertEqualMultiline(self, got, exp):
if (got + exp).find('\n') == -1:
self.assertEqual(got, exp)
else:
start_delim = "\n" + (" 8< ".join(["-----"] * 8)) + "\n"
end_delim = "\n" + (" >8 ".join(["-----"] * 8)) + "\n\n"
self.assertEqual(got, exp,
"got:" + start_delim + got + end_delim +
"expected:" + start_delim + exp + end_delim)

View File

@ -329,15 +329,7 @@ Binary file 'binary' has changed.
got = __canonise_diff(got)
exp = __canonise_diff(exp)
if (got + exp).find('\n') == -1:
self.assertEqual(got, exp)
else:
start_delim = "\n" + (" 8< ".join(["-----"] * 8)) + "\n"
end_delim = "\n" + (" >8 ".join(["-----"] * 8)) + "\n\n"
self.assertEqual(got, exp,
"got:" + start_delim + got + end_delim +
"expected:" + start_delim + exp + end_delim)
self.assertEqualMultiline(got, exp)
if __name__ == '__main__':
import unittest