linecache encoding fails in ipython notebook
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
testtools |
Triaged
|
Wishlist
|
Unassigned |
Bug Description
I was trying to play with subunit in ipython notebook:
import unittest
class MyTest(
def test_one(self):
assert True
def test_two(self):
assert False, "two failed..."
suite1 = unittest.
import subunit
import sys
test_result = subunit.
suite1.
The traceback I get is:
Traceback (most recent call last):
File "<ipython-
suite1.
File "/usr/lib/
test(result)
File "/usr/lib/
return self.run(*args, **kwds)
File "/usr/lib/
result.
File "/home/
self.
File "/home/
tb_content = TracebackConten
File "/home/
value = self._exc_
File "/home/
msgLines = format_
File "/home/
if evalue is None:
File "/home/
newtuple = _EncodingTuple(
File "/home/
# Source starting with UTF-8 BOM is either UTF-8 or a SyntaxError
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)
When I run the same code in a normal python file (utf-8 encoding) it runs fine and I see subunit output on stdout:
$ python subunitscratch.py
test: __main_
successful: __main_
test: __main_
failure: __main_
Traceback (most recent call last):
File "subunitscratch
assert False, "two failed..."
AssertionError: two failed...
]
I'm guessing it's to do with the fact that running in ipython notebook means there's no encoding for the source file of a traceback...
Python 2.7.3
testrepository=
testtools==0.9.22
nose-subunit==0.2
python-
Aside: when I run the same code in the vanilla interpreter it runs ok but the traceback is less informative as there's no source file (expected):
suite.run(
test: __main_
failure: __main_
Traceback (most recent call last):
File "<stdin>", line 3, in test_one
AssertionError
]
description: | updated |
Could you provide a minimal example for this?