from nbstata.config import launch_stata, Config
from fastcore.test import test_eq
from textwrap import dedent
from unittest.mock import Mock
cell
Class representing a single code cell
Cell
Cell (kernel, code_w_magics, silent=False)
A class for managing execution of a single code cell
Some Cell
functionality can be tested apart from a kernel:
= Mock()
kernel1 = Config()
kernel1.nbstata_config
= '''disp "test output"'''
code_w_magics = Cell(kernel1, code_w_magics)
cell1 cell1.code
'disp "test output"'
=False)
launch_stata(splash= StataSession()
kernel1.stata_session = Cell(kernel1, code_w_magics)
cell1a cell1a.run()
test output
= dedent('''\
code_w_magics *%%quietly
disp "test output"
''')
= Cell(kernel1, code_w_magics)
cell2 True) test_eq(cell2.quietly,
cell2.run()
'echo'] = 'True'
kernel1.nbstata_config.env[
= '''disp "test output"'''
code_w_magics = Cell(kernel1, code_w_magics)
cell3 False) test_eq(cell3.noecho,
cell3.run()
. disp "test output"
test output
= dedent('''\
code_w_magics *%%noecho
#delimit cr
disp "test output"
''')
= Cell(kernel1, code_w_magics)
cell4 True) test_eq(cell4.noecho,
cell4.run()
test output