Exemplo n.º 1
0
 def test_empty_code_cell(self):
     cc = new_code_cell()
     self.assertEqual(cc.cell_type, "code")
     self.assertEqual("input" not in cc, True)
     self.assertEqual("prompt_number" not in cc, True)
     self.assertEqual(cc.outputs, [])
     self.assertEqual(cc.collapsed, False)
Exemplo n.º 2
0
def sample_notebook_v3():
    return new_notebook(
        worksheets=[
            new_worksheet(
                cells=[new_code_cell("1 + 1"), new_text_cell("markdown", "Hi")]
            )
        ]
    )
Exemplo n.º 3
0
 def test_code_cell(self):
     cc = new_code_cell(input="a=10", prompt_number=0, collapsed=True)
     cc.outputs = [
         new_output(output_type="pyout",
                    output_svg="foo",
                    output_text="10",
                    prompt_number=0)
     ]
     self.assertEqual(cc.input, "a=10")
     self.assertEqual(cc.prompt_number, 0)
     self.assertEqual(cc.language, "python")
     self.assertEqual(cc.outputs[0].svg, "foo")
     self.assertEqual(cc.outputs[0].text, "10")
     self.assertEqual(cc.outputs[0].prompt_number, 0)
     self.assertEqual(cc.collapsed, True)
Exemplo n.º 4
0
    new_worksheet,
)

# some random base64-encoded *text*
png = encodebytes(os.urandom(5)).decode("ascii")
jpeg = encodebytes(os.urandom(6)).decode("ascii")

ws = new_worksheet()

ws.cells.append(new_text_cell(
    "html",
    source="Some NumPy Examples",
))

ws.cells.append(
    new_code_cell(input="import numpy", prompt_number=1, collapsed=False))

ws.cells.append(new_text_cell(
    "markdown",
    source="A random array",
))

ws.cells.append(new_text_cell(
    "raw",
    source="A random array",
))

ws.cells.append(new_heading_cell("My Heading", level=2))

ws.cells.append(
    new_code_cell(input="a = numpy.random.rand(100)",
Exemplo n.º 5
0
 def test_worksheet(self):
     cells = [new_code_cell(), new_text_cell("html")]
     ws = new_worksheet(cells=cells)
     self.assertEqual(ws.cells, cells)