py.test munging strings in asserts?

T

Timothy Grant

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.
 
J

Johnny deBris

Timothy said:
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 "..."?
Some grepping on '...' revealed that there's some string munging going
on in py/code/safe_repr.py, In py/test/terminal/terminal.py, in
TerminalSession, there's a method 'repr_locals' that uses it, I guess
you have to override that or something if you want to change this
behaviour...

Cheers,

Guido Wesdorp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top