py.test munging strings in asserts?

Timothy Grant timothy.grant at gmail.com
Thu Apr 20 23:14:51 EDT 2006


I'm playing around with py.test and writing a parser for it's output
for use in TextMate.

I've run into what appears to be a strange phenomenon, but which is
likely me doing something wrong.

I'm writing a test to test some HTML output and the test fails for
several reasons, all of which I understand but one.

Here's the output (I've surrounded the problem area with *** to make
it a little more visible.

========================================================
    def test_error_summary():
        text = '''<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>PyTestMate</title>

    <style type="text/css">
    .error {color : #FF0000}
    </style>

    </head>
    <body>
    <p>Error in <a
href="txmt://open/?url=file:///Users/tjg/code/textmate/test_pytestmate.py&line=17">/Users/tjg/code/textmate/test_pytestmate.py</a>
at line 17</p>
    <pre>
    [/Users/tjg/code/textmate/test_pytestmate.py:17]
    </pre>
    </body>
    </html>'''

        assert pytestmate.create_output(
            ['[/Users/tjg/code/textmate/test_pytestmate.py:17]']
E           ) == text
>       assert '<html>\n<head>\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n<title>PyTestMate</title>\n\n***<...mate/test_pytestmate.py***</a> at line 17<br/><pre>[/Users/tjg/code/textmate/test_pytestmate.py:17]</pre></body>\n</html>' == '<html>\n<head>\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n<title>PyTestMate</title>\n\n***<...st_pytestmate.py***</a> at line 17</p>\n<pre>\n[/Users/tjg/code/textmate/test_pytestmate.py:17]\n</pre>\n</body>\n</html>'
         +  where '<html>\n<head>\n<meta http-equiv="Content-Type"
content="text/html; charset=utf-8"
/>\n<title>PyTestMate</title>\n\n<...mate/test_pytestmate.py</a> at
line 17<br/><pre>[/Users/tjg/code/textmate/test_pytestmate.py:17]</pre></body>\n</html>'
= <function create_output at
0x42e870>(['[/Users/tjg/code/textmate/test_pytestmate.py:17]'])
         +    where <function create_output at 0x42e870> =
pytestmate.create_output

[/Users/tjg/code/textmate/test_pytestmate.py:55]
===============================================

granted the left side of that equality could be messed up due to
create_output() NOT doing the right thing. But the right side is
simply the contents of the variable "text" so WHY is the first part of
the path being substituted with "..."?

Any insight greatly appreciated.

--
Stand Fast,
    tjg.



More information about the Python-list mailing list