def testPrintsDiff(self): out = compat.StringIO() with self.assertRaises(AssertionError): th.assertJsonEqual([], [1], out) lines = out.getvalue().splitlines() # diff output includes \n\n, which becomes empty entry from splitlines # get rid of them. lines = list(filter(None, lines)) th.assertStartsWith(lines[0], '--- calculated') th.assertStartsWith(lines[1], '+++ ideal')
def testStarts(self): s = 'abcd' th.assertStartsWith(s, 'ab') with self.assertRaises(AssertionError): th.assertStartsWith(s, 'b')