very puzzling doctest behaviour

A

André

Hi everyone,

I've run into a very puzzling doctest behaviour - I'm trying to narrow
down the case of it but I'm dealing with multiple files being imported
for one of the case and I have not, so far, created a simple example.
However, just in case someone had run into something similar, I
thought I would ask.

I am using the doctest.testfile() interface to load up tests that
resides in a text file. Here's a description of the puzzling feature.

==== file 1: all tests pass ====
title <
========================

So far, nothing surprising...

==== file 2: we have a failure ====
title <

+ 400 lines of text and further tests
========================
The second expected "<" fails; instead, we get "&lt;"

==== file 3: all tests pass ====
title &lt;

+ 400 lines of text and further tests
========================

Upon further inspection, I find in module_a that, if I comment out a
line like
import module_b
then, tests in file 2 pass again. So, I figure the problem is in
module_b.
I then did

==== file 4: one failure ====
title <

+ 400 lines of text and further tests
========================

Again, this can be "fixed" by changing the expected output of the
second test

==== file 5: no failure ====
title &lt;

+ 400 lines of text and further tests
========================

As mentioned, I have not succeeded in narrowing it down further.
However, has anyone observed such a behaviour of doctests before?


André
 
A

André

Oops, sorry, I made an error in the original description of the
problem (test 4 & 5 below)

Hi everyone,

I've run into a very puzzling doctest behaviour - I'm trying to narrow
down the case of it but I'm dealing with multiple files being imported
for one of the case and I have not, so far, created a simple example.
However, just in case someone had run into something similar, I
thought I would ask.

I am using the doctest.testfile() interface to load up tests that
resides in a text file. Here's a description of the puzzling feature.

==== file 1: all tests pass ====
title
<
========================

So far, nothing surprising...

==== file 2: we have a failure ====
title
<

+ 400 lines of text and further tests
========================
The second expected "<" fails; instead, we get "&lt;"

==== file 3: all tests pass ====
title
&lt;

+ 400 lines of text and further tests
========================

Upon further inspection, I find in module_a that, if I comment out a
line like
import module_b
then, tests in file 2 pass again. So, I figure the problem is in
module_b.
I then did

Sorry, file 4 had NO failure ... so it looked like the problem was NOT
in module_b; and yet, when I commented its import in module_a, the
problem went away.
 
G

Gabriel Genellina

Are you playing with sys.stdout, replacing it with another object, or
changing its encoding? That's the only way to get "&lt;" when printing "<"
that I can think of.
 
A

André

Are you playing with sys.stdout, replacing it with another object, or
changing its encoding? That's the only way to get "&lt;" when printing "<"
that I can think of.
Hmmm, yes I do, somewhere (locally I thought) in a function embedded
in yet another module. This gives me something to look for.

Thanks for the suggestion.

André

 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top