473,394 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

py.test munging strings in asserts?

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.
Apr 21 '06 #1
1 1422
Timothy Grant wrote:

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
Apr 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: mercuryprey | last post by:
Hi, I'm pretty new to Python, to programming overall...so how would I make something where the user inputs multiple words in a string - like "connect 123.123.123.123 21 user password" or similar,...
41
by: Roy Smith | last post by:
I've used the standard unittest (pyunit) module on a few projects in the past and have always thought it basicly worked fine but was just a little too complicated for what it did. I'm starting a...
18
by: Ralf W. Grosse-Kunstleve | last post by:
My initial proposal (http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html) didn't exactly get a warm welcome... And Now for Something Completely Different: class autoinit(object):...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
34
by: Kishor | last post by:
Hi Friends Click here : www.c4swimmers.esmartguy.com to Test Your C Programming Strengths. You can find Tricky Questions on C, Interview type queries on C, Infrequently Answered Questions in C...
5
by: | last post by:
Hi, I'm trying to use the cookie munging session handling behaviour of asp.net instead of cookies themselves as I'm finding quite a few people are barring cookies (especially AOL users). If I...
35
by: Cor | last post by:
Hallo, I have promised Jay B yesterday to do some tests. The subject was a string evaluation that Jon had send in. Jay B was in doubt what was better because there was a discussion in the C#...
13
by: Moohoo | last post by:
I have two sorted containers, and I wish to know if any items from one container exist in the second container. Is there anything in the standard library to do this? Thanks
35
by: RobG | last post by:
Seems developers of mobile applications are pretty much devoted to UA sniffing: <URL: http://wurfl.sourceforge.net/vodafonerant/index.htm > -- Rob
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.