Code review comment for lp:~jml/testtools/unprintable-assertThat-804127

Revision history for this message
Martin Packman (gz) wrote :

An update on where I am, as we've failed to connect on IRC a couple of times.

Fixing problem 1) above with %s without changing the current behaviour is a little complex as there are several different variations on the output desired, and also changes across Python implementations even in the trivial case due to different prefixes. So, I got a little stuck trying to write a does-everything fancy repr without breaking the current behaviour. Simply changing everything to %r would work* but lose the breaking up of multiline strings and new regexp backslash behaviour. I'm nearly there with a proper fix, it's just fiddly.

*Mostly. One kind of problem currently is like:

    from testtools import TestCase
    from testtools.matchers import Equals

    class Test(TestCase):

        def test_lost_control(self):
            self.assertThat("\x1b[31;1m", Equals("CSI 32 ; 1 m"), verbose=True)

    if __name__ == "__main__":
        import unittest
        unittest.main()

This sort is particularly fun as C0 codes are perfectly valid in returns from __repr__ functions, so even with strings fixed other objects can still give surprising test result output.

« Back to merge proposal