Question

I am working on an web application using flask, postgresql and sqlalchemy and coding in Eclipse. I am using python unittest to test basic functions.

So I was editing my code and by mistake I typed ∫ in a comment. Since it was in a comment I did not bother to remove it(I know about encodings and all but still I did it!) I ran my unittest and it did not run any test for obvious reason. But the problem is I was not able to find reason of error until I ran the local server and then I was able to find the error.

I have similar problems in past where some unknown small mistake stops my test to even begin without even informing me the source of error.

So my question is there any way to find source of error while using python unittest module and avoid situations like mentioned above?

Was it helpful?

Solution

Running a basic unittest example with a # ∫ comment added gives me the following error:

  File "example.py", line 4  
SyntaxError: Non-ASCII character '\xe2' in file x.py on line 4, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

With python -m unittest example I get the same exception (with a somewhat longer backtrace).

So it seems this is not an unittest issue. Are you using an Eclipse plugin to run your tests? If so, try running it from the command line; if that works fine this is likely a bug in that plugin.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top