##// END OF EJS Templates
Merge pull request #1495 from rkern/fix-hyperobject-pprint...
Merge pull request #1495 from rkern/fix-hyperobject-pprint BUG: Fix pretty-printing for overzealous objects Some classes use __getattr__ to automatically create requested attributes. The recent trend of LINQ-like query objects is what I ran into. This confuses the pretty-printing machinery that tests for _repr_pretty_. This pull request fixes many of these problems by simply testing if the _repr_pretty_ attribute is callable. This may still be confused by certain mocking frameworks, but it's a good start.

File last commit:

r4406:0251893c
r6272:873e3647 merge
Show More
test_nbbase.py
41 lines | 1.1 KiB | text/x-python | PythonLexer
from unittest import TestCase
from ..nbbase import (
NotebookNode,
new_code_cell, new_text_cell, new_notebook
)
class TestCell(TestCase):
def test_empty_code_cell(self):
cc = new_code_cell()
self.assertEquals(cc.cell_type,'code')
self.assertEquals('code' not in cc, True)
self.assertEquals('prompt_number' not in cc, True)
def test_code_cell(self):
cc = new_code_cell(code='a=10', prompt_number=0)
self.assertEquals(cc.code, u'a=10')
self.assertEquals(cc.prompt_number, 0)
def test_empty_text_cell(self):
tc = new_text_cell()
self.assertEquals(tc.cell_type, 'text')
self.assertEquals('text' not in tc, True)
def test_text_cell(self):
tc = new_text_cell('hi')
self.assertEquals(tc.text, u'hi')
class TestNotebook(TestCase):
def test_empty_notebook(self):
nb = new_notebook()
self.assertEquals(nb.cells, [])
def test_notebooke(self):
cells = [new_code_cell(),new_text_cell()]
nb = new_notebook(cells=cells)
self.assertEquals(nb.cells,cells)