Esempio n. 1
0
    def test_extra_sys_argv(self):
        filename = 'spam.py'
        port = 8888
        debug_id = 1
        debug_options = {'x': 'y'}
        sys.argv = [filename, '--abc', 'xyz', '42']
        debug(filename,
              port,
              debug_id,
              debug_options,
              'script',
              _run=self._run,
              _prog='eggs')

        self.assertEqual(
            self.argv,
            _get_args('--file',
                      'spam.py',
                      '--abc',
                      'xyz',
                      '42',
                      ptvsd_extras=['--client', LOCALHOST]))
        self.assertEqual(self.addr, Address.as_client(None, port))
        self.assertEqual(self.kwargs, {
            'singlesession': True,
        })
Esempio n. 2
0
    def test_executable(self):
        addr = (None, 8888)
        run_file(addr, 'spam.py', _run=self._run)

        self.assertEqual(self.argv,
                         _get_args('--file', 'spam.py', prog=sys.argv[0]))

        self.assertEqual(self.addr, Address.as_server(*addr))
        self.assertEqual(self.kwargs, {})
Esempio n. 3
0
    def test_server(self):
        addr = Address.as_server('10.0.1.1', 8888)
        run_module(addr, 'spam', _run=self._run, _prog='eggs')

        self.assertEqual(self.argv,
                         _get_args('--module', '--file', 'spam:'))

        self.assertEqual(self.addr, Address.as_server(*addr))
        self.assertEqual(self.kwargs, {})
Esempio n. 4
0
    def test_local(self):
        addr = (None, 8888)
        run_file(addr, 'spam.py', _run=self._run, _prog='eggs')

        self.assertEqual(self.argv,
                         _get_args('--file', 'spam.py'))

        self.assertEqual(self.addr, Address.as_server(*addr))
        self.assertEqual(self.kwargs, {})
Esempio n. 5
0
    def test_extra(self):
        addr = (None, 8888)
        run_module(addr, 'spam', '--vm_type', 'xyz', '--', '--DEBUG',
                   _run=self._run, _prog='eggs')

        self.assertEqual(self.argv,
                         _get_args(
                             '--module', '--file', 'spam:', '--DEBUG',
                             ptvsd_extras=['--vm_type', 'xyz']))

        self.assertEqual(self.addr, Address.as_server(*addr))
        self.assertEqual(self.kwargs, {})
Esempio n. 6
0
    def test_remote(self):
        addr = ('1.2.3.4', 8888)
        run_module(addr, 'spam', _run=self._run, _prog='eggs')

        self.assertEqual(self.argv,
                         _get_args('--module', '--file', 'spam:',
                                   ptvsd_extras=['--client', '1.2.3.4']))

        self.assertEqual(self.addr, Address.as_client(*addr))
        self.assertEqual(self.kwargs, {
            'singlesession': True,
        })
Esempio n. 7
0
    def test_run(self):
        pydevd = FakePyDevd('pydevd/pydevd.py', self._main)
        addr = (None, 8888)
        run_file(addr, 'spam.py', _pydevd=pydevd, _install=self._install)

        self.assertEqual(self.pydevd, pydevd)
        self.assertEqual(self.addr, Address.as_server(*addr))
        self.assertEqual(self.kwargs, {})
        self.assertEqual(self.maincalls, 1)
        self.assertEqual(sys.argv,
                         _get_args('--file', 'spam.py', prog=sys.argv[0]))
        self.assertEqual(self.exitcode, -1)
Esempio n. 8
0
    def test_remote_localhost(self):
        addr = Address.as_client(None, 8888)
        run_file(addr, 'spam.py', _run=self._run, _prog='eggs')

        self.assertEqual(self.argv,
                         _get_args(
                             '--file', 'spam.py',
                             ptvsd_extras=['--client', 'localhost']))

        self.assertEqual(self.addr, Address.as_client(*addr))
        self.assertEqual(self.kwargs, {
            'singlesession': True,
        })
Esempio n. 9
0
    def test_exit(self):
        self.mainexc = SystemExit(1)
        pydevd = FakePyDevd('pydevd/pydevd.py', self._main)
        addr = (None, 8888)
        with self.assertRaises(SystemExit):
            run_file(addr, 'spam.py', _pydevd=pydevd, _install=self._install)

        self.assertEqual(self.pydevd, pydevd)
        self.assertEqual(self.addr, Address.as_server(*addr))
        self.assertEqual(self.kwargs, {})
        self.assertEqual(self.maincalls, 1)
        self.assertEqual(sys.argv,
                         _get_args('--file', 'spam.py', prog=sys.argv[0]))
        self.assertEqual(self.exitcode, 1)
Esempio n. 10
0
    def test_failure(self):
        self.mainexc = RuntimeError('boom!')
        pydevd = FakePyDevd('pydevd/pydevd.py', self._main)
        addr = (None, 8888)
        with self.assertRaises(RuntimeError) as cm:
            run_file(addr, 'spam.py', _pydevd=pydevd, _install=self._install)
        exc = cm.exception

        self.assertEqual(self.pydevd, pydevd)
        self.assertEqual(self.addr, Address.as_server(*addr))
        self.assertEqual(self.kwargs, {})
        self.assertEqual(self.maincalls, 1)
        self.assertEqual(sys.argv,
                         _get_args('--file', 'spam.py', prog=sys.argv[0]))
        self.assertEqual(self.exitcode, -1)  # TODO: Is this right?
        self.assertIs(exc, self.mainexc)
Esempio n. 11
0
    def test_unsupported(self):
        filename = 'spam'
        port = 8888
        debug_id = 1
        debug_options = {'x': 'y'}
        sys.argv = [filename]
        debug(filename,
              port,
              debug_id,
              debug_options,
              '???',
              _run=self._run,
              _prog='eggs')

        self.assertEqual(
            self.argv,
            _get_args('--file', 'spam', ptvsd_extras=['--client', LOCALHOST]))
        self.assertEqual(self.addr, Address.as_client(None, port))
        self.assertEqual(self.kwargs, {
            'singlesession': True,
        })