test_nbbase.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from unittest import TestCase
  2. from ..nbbase import (
  3. NotebookNode,
  4. new_code_cell, new_text_cell, new_notebook
  5. )
  6. class TestCell(TestCase):
  7. def test_empty_code_cell(self):
  8. cc = new_code_cell()
  9. self.assertEqual(cc.cell_type,'code')
  10. self.assertEqual('code' not in cc, True)
  11. self.assertEqual('prompt_number' not in cc, True)
  12. def test_code_cell(self):
  13. cc = new_code_cell(code='a=10', prompt_number=0)
  14. self.assertEqual(cc.code, u'a=10')
  15. self.assertEqual(cc.prompt_number, 0)
  16. def test_empty_text_cell(self):
  17. tc = new_text_cell()
  18. self.assertEqual(tc.cell_type, 'text')
  19. self.assertEqual('text' not in tc, True)
  20. def test_text_cell(self):
  21. tc = new_text_cell('hi')
  22. self.assertEqual(tc.text, u'hi')
  23. class TestNotebook(TestCase):
  24. def test_empty_notebook(self):
  25. nb = new_notebook()
  26. self.assertEqual(nb.cells, [])
  27. def test_notebooke(self):
  28. cells = [new_code_cell(),new_text_cell()]
  29. nb = new_notebook(cells=cells)
  30. self.assertEqual(nb.cells,cells)