File: test_nbbase.py

package info (click to toggle)
ipython 0.13.1-2%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 15,752 kB
  • sloc: python: 69,537; makefile: 355; lisp: 272; sh: 80; objc: 37
file content (41 lines) | stat: -rw-r--r-- 1,118 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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)