Beispiel #1
0
 def test_import_bpython_fails(self, *args):
     original = builtin_commands.Shell.run_bpython
     property_mock = mock.PropertyMock(side_effect=ImportError)
     try:
         builtin_commands.Shell.run_bpython = property_mock
         shell_cmd = builtin_commands.Shell()
         shell_cmd.configure(mock.Mock())
         shell_cmd.setup()
         with mock.patch("IPython.start_ipython") as start_ipython:
             cli.run_from_command_line()
             self.assertTrue(start_ipython.called)
     finally:
         builtin_commands.Shell.run_bpython = original
Beispiel #2
0
 def test_import_ipython_and_bpython_fails(self, *args):
     ioriginal = builtin_commands.Shell.run_ipython
     boriginal = builtin_commands.Shell.run_bpython
     property_mock = mock.PropertyMock(side_effect=ImportError)
     try:
         builtin_commands.Shell.run_ipython = property_mock
         builtin_commands.Shell.run_bpython = property_mock
         shell_cmd = builtin_commands.Shell()
         shell_cmd.configure(mock.Mock())
         shell_cmd.setup()
         with mock.patch("code.InteractiveConsole.interact") as interact:
             cli.run_from_command_line()
             self.assertTrue(interact.called)
     finally:
         builtin_commands.Shell.run_ipython = ioriginal
         builtin_commands.Shell.run_bpython = boriginal
Beispiel #3
0
    def test_default_shell_command(self, *args):
        mockeable_shell_calls = {
            "ipython": "IPython.start_ipython",
            "bpython": "bpython.embed",
            "plain": "code.InteractiveConsole.interact",
        }

        shell_cmd = builtin_commands.Shell()
        shell_cmd.configure(mock.Mock())
        shell_cmd.setup()
        shells = shell_cmd.shells

        first_shell = tuple(shells.keys())[0]
        to_mock = mockeable_shell_calls[first_shell]

        with mock.patch(to_mock) as call:
            cli.run_from_command_line()
            self.assertTrue(call.called)