Skip to content

Add test for code inspection in MockMetaData with ipython #62

@tkilias

Description

@tkilias

The code inspection in MockMetaData can make problems under Jupyter, for that reason, we need to test it with ipython.

You can run code under ipython as follows:


import IPython
from traitlets.config import Config
import multiprocessing


def run_ipython_first():
    c = Config()
    c.InteractiveShellApp.code_to_run = """
        print('exit1')
        exit()
    """
    c.InteractiveShell.confirm_exit = False
    IPython.start_ipython(config=c)
    print("after1")


def run_ipython_second():
    c = Config()
    c.InteractiveShellApp.code_to_run = """
        print('assert2')
        assert 1==0
    """
    c.InteractiveShell.confirm_exit = False
    IPython.start_ipython(config=c)
    print("after2")  # This will never print because the IPython instance will raise an AssertionError


if __name__ == "__main__":
    p1 = multiprocessing.Process(target=run_ipython_first)
    p2 = multiprocessing.Process(target=run_ipython_second)

    p1.start()
    p1.join()  # Wait for the first process to finish

    p2.start()
    p2.join()  # Wait for the second process to finish

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactoringCode improvement without behavior change

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions