Esempio n. 1
0
    def test_monkey_patch_args_no_indc_without_pydevd(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {'client':'127.0.0.1', 'port': '0'}
            check=['C:\\bin\\python.exe', 'target.py', 'connect(\\"127.0.0.1\\")', 'bar']
            sys.original_argv = ['pydevd.py', '--a=1', 'b', '--c=2', '--file', 'ignore_this.py']

            if sys.platform == 'win32':
                self.assertEqual(pydev_monkey.patch_args(check), [
                    'C:\\bin\\python.exe',
                    '"pydevd.py"',
                    '"--a=1"',
                    '"b"',
                    '"--c=2"',
                    '"--file"',
                    'target.py',
                    'connect(\\"127.0.0.1\\")',
                    'bar',
                ])
            else:
                self.assertEqual(pydev_monkey.patch_args(check), [
                    'C:\\bin\\python.exe',
                    'pydevd.py',
                    '--a=1',
                    'b',
                    '--c=2',
                    '--file',
                    'target.py',
                    'connect(\\"127.0.0.1\\")',
                    'bar',
                ])
        finally:
            SetupHolder.setup = original
    def test_monkey_patch_args_module(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {'client':'127.0.0.1', 'port': '0'}
            check=['C:\\bin\\python.exe', '-m', 'test']
            sys.original_argv = ['pydevd', '--multiprocess']
            if sys.platform == 'win32':
                self.assertEqual(pydev_monkey.patch_args(check), [
                    'C:\\bin\\python.exe',
                    '"pydevd"',
                    '"--module"',
                    '"--multiprocess"',
                    'test',
                ])
            else:
                self.assertEqual(pydev_monkey.patch_args(check), [
                    'C:\\bin\\python.exe',
                    'pydevd',
                    '--module',
                    '--multiprocess',
                    'test',
                ])
        finally:
            SetupHolder.setup = original
    def test_monkey_patch_args_no_indc_without_pydevd(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {'client':'127.0.0.1', 'port': '0'}
            check=['C:\\bin\\python.exe', 'target.py', 'connect(\\"127.0.0.1\\")', 'bar']
            sys.original_argv = ['pydevd.py', '--a=1', 'b', '--c=2', '--file', 'ignore_this.py']

            if sys.platform == 'win32':
                self.assertEqual(pydev_monkey.patch_args(check), [
                    'C:\\bin\\python.exe',
                    '"pydevd.py"',
                    '"--a=1"',
                    '"b"',
                    '"--c=2"',
                    '"--file"',
                    'target.py',
                    'connect(\\"127.0.0.1\\")',
                    'bar',
                ])
            else:
                self.assertEqual(pydev_monkey.patch_args(check), [
                    'C:\\bin\\python.exe',
                    'pydevd.py',
                    '--a=1',
                    'b',
                    '--c=2',
                    '--file',
                    'target.py',
                    'connect(\\"127.0.0.1\\")',
                    'bar',
                ])
        finally:
            SetupHolder.setup = original
Esempio n. 4
0
    def test_monkey_patch_args_module(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {'client': '127.0.0.1', 'port': '0'}
            check = ['C:\\bin\\python.exe', '-m', 'test']
            sys.original_argv = ['pydevd', '--multiprocess']
            if sys.platform == 'win32':
                self.assertEqual(pydev_monkey.patch_args(check), [
                    'C:\\bin\\python.exe',
                    '"pydevd"',
                    '"--module"',
                    '"--multiprocess"',
                    'test',
                ])
            else:
                self.assertEqual(pydev_monkey.patch_args(check), [
                    'C:\\bin\\python.exe',
                    'pydevd',
                    '--module',
                    '--multiprocess',
                    'test',
                ])
        finally:
            SetupHolder.setup = original
Esempio n. 5
0
    def test_monkey_patch_args_no_indc(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {'client':'127.0.0.1', 'port': '0'}
            check=['C:\\bin\\python.exe', 'connect(\\"127.0.0.1\\")']
            sys.original_argv = ['my', 'original', 'argv']
            if sys.platform == 'win32':
                self.assertEqual(pydev_monkey.patch_args(check), [
                    'C:\\bin\\python.exe', '"my"', '"original"', '"argv"', 'connect(\\"127.0.0.1\\")'])
            else:
                self.assertEqual(pydev_monkey.patch_args(check), [
                    'C:\\bin\\python.exe', 'my', 'original', 'argv', 'connect(\\"127.0.0.1\\")'])
        finally:
            SetupHolder.setup = original
    def test_monkey_patch_args_no_indc(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {'client':'127.0.0.1', 'port': '0'}
            check=['C:\\bin\\python.exe', 'connect(\\"127.0.0.1\\")']
            sys.original_argv = ['my', 'original', 'argv']
            if sys.platform == 'win32':
                self.assertEqual(pydev_monkey.patch_args(check), [
                    'C:\\bin\\python.exe', '"my"', '"original"', '"argv"', 'connect(\\"127.0.0.1\\")'])
            else:
                self.assertEqual(pydev_monkey.patch_args(check), [
                    'C:\\bin\\python.exe', 'my', 'original', 'argv', 'connect(\\"127.0.0.1\\")'])
        finally:
            SetupHolder.setup = original
Esempio n. 7
0
    def test_monkey_patch_args_module(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {"client": "127.0.0.1", "port": "0", "multiprocess": True}
            check = ["C:\\bin\\python.exe", "-m", "test"]
            from _pydevd_bundle.pydevd_command_line_handling import get_pydevd_file

            self.assertEqual(
                pydev_monkey.patch_args(check),
                [
                    "C:\\bin\\python.exe",
                    get_pydevd_file(),
                    "--module",
                    "--port",
                    "0",
                    "--client",
                    "127.0.0.1",
                    "--multiprocess",
                    "--file",
                    "test",
                ],
            )
        finally:
            SetupHolder.setup = original
Esempio n. 8
0
def test_monkey_patch_args_no_indc_without_pydevd():
    original = SetupHolder.setup
    from _pydevd_bundle.pydevd_command_line_handling import get_pydevd_file

    try:
        SetupHolder.setup = {'client': '127.0.0.1', 'port': '0'}
        check = [
            'C:\\bin\\python.exe', 'target.py', 'connect(\\"127.0.0.1\\")',
            'bar'
        ]
        assert pydev_monkey.patch_args(check) == [
            'C:\\bin\\python.exe',
            get_pydevd_file(),
            '--port',
            '0',
            '--ppid',
            str(os.getpid()),
            '--client',
            '127.0.0.1',
            '--protocol-quoted-line',
            '--file',
            'target.py',
            '"connect(\\\\\\"127.0.0.1\\\\\\")"'
            if sys.platform == 'win32' else 'connect(\\"127.0.0.1\\")',
            'bar',
        ]
    finally:
        SetupHolder.setup = original
Esempio n. 9
0
def test_monkey_patch_args_c_flag_inline():
    original = SetupHolder.setup

    try:
        SetupHolder.setup = {'client': '127.0.0.1', 'port': '0', 'ppid': os.getpid(), 'protocol-quoted-line': True, 'skip-notify-stdin': True}
        check = ['C:\\bin\\python.exe', '-X', 'faulthandler', '-cconnect("127.0.0.1")', 'arg1']
        debug_command = (
            "import sys; sys.path.insert(0, r\'%s\'); import pydevd; pydevd.PydevdCustomization.DEFAULT_PROTOCOL='quoted-line'; "
            'pydevd.settrace(host=\'127.0.0.1\', port=0, suspend=False, trace_only_current_thread=False, patch_multiprocessing=True, access_token=None, client_access_token=None, __setup_holder__=%s); '
            ''
            'connect("127.0.0.1")') % (pydev_src_dir, sorted_dict_repr(SetupHolder.setup))
        if sys.platform == "win32":
            debug_command = debug_command.replace('"', '\\"')
            debug_command = '"%s"' % debug_command
        res = pydev_monkey.patch_args(check)
        assert res == [
            'C:\\bin\\python.exe',
            '-X',
            'faulthandler',
            '-c',
            debug_command,
            'arg1'
        ]
    finally:
        SetupHolder.setup = original
Esempio n. 10
0
    def test_monkey_patch_args_indc(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {
                'client': '127.0.0.1',
                'port': '0',
                'protocol-quoted-line': True
            }
            check = ['C:\\bin\\python.exe', '-u', '-c', 'connect("127.0.0.1")']
            debug_command = (
                "import sys; sys.path.insert(0, r\'%s\'); import pydevd; pydevd.PydevdCustomization.DEFAULT_PROTOCOL='quoted-line'; "
                'pydevd.settrace(host=\'127.0.0.1\', port=0, suspend=False, trace_only_current_thread=False, patch_multiprocessing=True, access_token=None, client_access_token=None); '
                ''
                "from pydevd import SetupHolder; "
                "SetupHolder.setup = %s; "
                ''
                'connect("127.0.0.1")') % (pydev_src_dir, SetupHolder.setup)
            if sys.platform == "win32":
                debug_command = debug_command.replace('"', '\\"')
                debug_command = '"%s"' % debug_command
            res = pydev_monkey.patch_args(check)
            self.assertEqual(
                res, ['C:\\bin\\python.exe', '-u', '-c', debug_command])
        finally:
            SetupHolder.setup = original
Esempio n. 11
0
def test_monkey_patch_c_program_arg(use_bytes):
    original = SetupHolder.setup
    from _pydevd_bundle.pydevd_command_line_handling import get_pydevd_file

    try:
        SetupHolder.setup = {'client': '127.0.0.1', 'port': '0'}
        check = ['C:\\bin\\python.exe', '-u', 'target.py', '-c', '-áéíóú']

        encode = lambda s: s
        if use_bytes:
            if not IS_PY2:
                check = [c.encode('utf-8') for c in check]
                encode = lambda s: s.encode('utf-8')
        else:
            if IS_PY2:
                check = [c.decode('utf-8') for c in check]
                encode = lambda s: s.decode('utf-8')

        assert pydev_monkey.patch_args(check) == [
            encode('C:\\bin\\python.exe'),
            encode('-u'),
            get_pydevd_file(), '--port', '0', '--ppid',
            str(os.getpid()), '--client', '127.0.0.1',
            '--protocol-quoted-line', '--file',
            encode('target.py'),
            encode('-c'),
            encode('-áéíóú')
        ]
    finally:
        SetupHolder.setup = original
Esempio n. 12
0
    def test_monkey_patch_args_indc(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {'client': '127.0.0.1', 'port': '0'}
            check = ['C:\\bin\\python.exe', '-u', '-c', 'connect("127.0.0.1")']
            debug_command = (
                'import sys; sys.path.append(r\'%s\'); import pydevd; '
                'pydevd.settrace(host=\'127.0.0.1\', port=0, suspend=False, trace_only_current_thread=False, patch_multiprocessing=True); '
                ''
                "from pydevd import SetupHolder; "
                "SetupHolder.setup = %s; "
                ''
                'connect("127.0.0.1")') % (pydev_src_dir, SetupHolder.setup)
            if sys.platform == "win32":
                debug_command = debug_command.replace('"', '\\"')
                debug_command = '"%s"' % debug_command
            res = pydev_monkey.patch_args(check)
            self.assertEqual(res, [
                'C:\\bin\\python.exe',
                '-u',
                '-c',
                debug_command
            ])
        finally:
            SetupHolder.setup = original
Esempio n. 13
0
    def test_monkey_patch_args_no_indc_without_pydevd(self):
        original = SetupHolder.setup
        from _pydevd_bundle.pydevd_command_line_handling import get_pydevd_file

        try:
            SetupHolder.setup = {"client": "127.0.0.1", "port": "0"}
            check = ["C:\\bin\\python.exe", "target.py", 'connect(\\"127.0.0.1\\")', "bar"]

            self.assertEqual(
                pydev_monkey.patch_args(check),
                [
                    "C:\\bin\\python.exe",
                    get_pydevd_file(),
                    "--port",
                    "0",
                    "--client",
                    "127.0.0.1",
                    "--file",
                    "target.py",
                    'connect(\\"127.0.0.1\\")',
                    "bar",
                ],
            )
        finally:
            SetupHolder.setup = original
Esempio n. 14
0
def test_monkey_patch_args_module_single_arg():
    original = SetupHolder.setup

    try:
        SetupHolder.setup = {'client': '127.0.0.1', 'port': '0', 'multiprocess': True}
        check = ['C:\\bin\\python.exe', '-mtest', 'bar']
        from _pydevd_bundle.pydevd_command_line_handling import get_pydevd_file
        assert pydev_monkey.patch_args(check) == [
            'C:\\bin\\python.exe',
            get_pydevd_file(),
            '--module',
            '--port',
            '0',
            '--ppid',
            str(os.getpid()),
            '--client',
            '127.0.0.1',
            '--multiprocess',
            '--protocol-quoted-line',
            '--file',
            'test',
            'bar',
        ]
    finally:
        SetupHolder.setup = original
Esempio n. 15
0
    def test_monkey_patch_args_no_indc_without_pydevd(self):
        original = SetupHolder.setup
        from _pydevd_bundle.pydevd_command_line_handling import get_pydevd_file

        try:
            SetupHolder.setup = {'client': '127.0.0.1', 'port': '0'}
            check = [
                'C:\\bin\\python.exe', 'target.py', 'connect(\\"127.0.0.1\\")',
                'bar'
            ]

            self.assertEqual(pydev_monkey.patch_args(check), [
                'C:\\bin\\python.exe',
                get_pydevd_file(),
                '--port',
                '0',
                '--client',
                '127.0.0.1',
                '--file',
                'target.py',
                'connect(\\"127.0.0.1\\")',
                'bar',
            ])
        finally:
            SetupHolder.setup = original
Esempio n. 16
0
    def test_monkey_patch_args_module(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {
                'client': '127.0.0.1',
                'port': '0',
                'multiprocess': True
            }
            check = ['C:\\bin\\python.exe', '-m', 'test']
            from _pydevd_bundle.pydevd_command_line_handling import get_pydevd_file
            self.assertEqual(pydev_monkey.patch_args(check), [
                'C:\\bin\\python.exe',
                get_pydevd_file(),
                '--module',
                '--port',
                '0',
                '--client',
                '127.0.0.1',
                '--multiprocess',
                '--file',
                'test',
            ])
        finally:
            SetupHolder.setup = original
Esempio n. 17
0
    def test_monkey_patch_args_no_indc(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {'client': '127.0.0.1', 'port': '0'}
            check = [
                'C:\\bin\\python.exe', 'connect(\\"127.0.0.1\\")',
                'with spaces'
            ]
            from _pydevd_bundle.pydevd_command_line_handling import get_pydevd_file
            self.assertEqual(pydev_monkey.patch_args(check), [
                'C:\\bin\\python.exe',
                get_pydevd_file(),
                '--port',
                '0',
                '--client',
                '127.0.0.1',
                '--protocol-quoted-line',
                '--file',
                '"connect(\\\\\\"127.0.0.1\\\\\\")"'
                if sys.platform == 'win32' else 'connect(\\"127.0.0.1\\")',
                '"with spaces"' if sys.platform == 'win32' else 'with spaces',
            ])
        finally:
            SetupHolder.setup = original
Esempio n. 18
0
def test_monkey_patch_pathlib_args():
    try:
        import pathlib
    except ImportError:
        pytest.skip('pathlib not available.')

    check = [pathlib.Path('echo'), '"my"', '"args"']
    res = pydev_monkey.patch_args(check[:])
    assert res == check
Esempio n. 19
0
def test_monkey_patch_args_stdin():
    original = SetupHolder.setup

    try:
        SetupHolder.setup = {'client': '127.0.0.1', 'port': '0', 'multiprocess': True}
        check = ['C:\\bin\\python.exe', '-Xfaulthandler' , '-']
        # i.e.: we don't deal with the stdin.
        assert pydev_monkey.patch_args(check) == check
    finally:
        SetupHolder.setup = original
Esempio n. 20
0
    def test_skip_stdin(self):
        original = SetupHolder.setup
        try:
            SetupHolder.setup = {'client': '127.0.0.1', 'port': '0'}
            check = ['C:\\bin\\python.exe', '-', 'pip', 'setuptools']

            self.assertEqual(pydev_monkey.patch_args(check),
                             ['C:\\bin\\python.exe', '-', 'pip', 'setuptools'])
        finally:
            SetupHolder.setup = original
Esempio n. 21
0
def test_monkey_patch_args_no_indc_with_pydevd():
    original = SetupHolder.setup

    try:
        SetupHolder.setup = {'client': '127.0.0.1', 'port': '0'}
        check = ['C:\\bin\\python.exe', 'pydevd.py', 'connect(\\"127.0.0.1\\")', 'bar']

        assert pydev_monkey.patch_args(check) == [
            'C:\\bin\\python.exe', 'pydevd.py', 'connect(\\"127.0.0.1\\")', 'bar']
    finally:
        SetupHolder.setup = original
Esempio n. 22
0
    def test_monkey_patch_args_no_indc_with_pydevd(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {'client': '127.0.0.1', 'port': '0'}
            check = ['C:\\bin\\python.exe', 'pydevd.py', 'connect(\\"127.0.0.1\\")', 'bar']

            self.assertEqual(pydev_monkey.patch_args(check), [
                'C:\\bin\\python.exe', 'pydevd.py', 'connect(\\"127.0.0.1\\")', 'bar'])
        finally:
            SetupHolder.setup = original
Esempio n. 23
0
    def test_monkey_patch_args_no_indc_with_pydevd(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {"client": "127.0.0.1", "port": "0"}
            check = ["C:\\bin\\python.exe", "pydevd.py", 'connect(\\"127.0.0.1\\")', "bar"]

            self.assertEqual(
                pydev_monkey.patch_args(check), ["C:\\bin\\python.exe", "pydevd.py", 'connect(\\"127.0.0.1\\")', "bar"]
            )
        finally:
            SetupHolder.setup = original
Esempio n. 24
0
    def test_monkey_patch_args_no_indc_with_pydevd(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {'client':'127.0.0.1', 'port': '0'}
            check=['C:\\bin\\python.exe', 'pydevd.py', 'connect(\\"127.0.0.1\\")', 'bar']
            sys.original_argv = ['my', 'original', 'argv']

            self.assertEqual(pydev_monkey.patch_args(check), [
                'C:\\bin\\python.exe', 'pydevd.py', 'connect(\\"127.0.0.1\\")', 'bar'])
        finally:
            SetupHolder.setup = original
Esempio n. 25
0
    def test_monkey_patch_args_indc(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {'client': '127.0.0.1', 'port': '0'}
            check = [
                'C:\\bin\\python.exe', '-u', '-c', 'connect(\\"127.0.0.1\\")'
            ]
            sys.original_argv = []
            self.assertEqual(pydev_monkey.patch_args(check), [
                'C:\\bin\\python.exe', '-u', '-c',
                ('import sys; sys.path.append(r\'%s\'); import pydevd; '
                 'pydevd.settrace(host=\'127.0.0.1\', port=0, suspend=False, trace_only_current_thread=False, patch_multiprocessing=True); '
                 'connect(\\"127.0.0.1\\")') % pydev_src_dir
            ])
        finally:
            SetupHolder.setup = original
Esempio n. 26
0
    def test_monkey_patch_c_program_arg(self):
        original = SetupHolder.setup
        from _pydevd_bundle.pydevd_command_line_handling import get_pydevd_file

        try:
            SetupHolder.setup = {'client': '127.0.0.1', 'port': '0'}
            check = [
                'C:\\bin\\python.exe', '-u', 'target.py', '-c', '-another_arg'
            ]

            self.assertEqual(pydev_monkey.patch_args(check), [
                'C:\\bin\\python.exe', '-u',
                get_pydevd_file(), '--port', '0', '--client', '127.0.0.1',
                '--file', 'target.py', '-c', '-another_arg'
            ])
        finally:
            SetupHolder.setup = original
    def test_monkey_patch_args_no_indc(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {'client': '127.0.0.1', 'port': '0'}
            check = ['C:\\bin\\python.exe', 'connect(\\"127.0.0.1\\")']
            from _pydevd_bundle.pydevd_command_line_handling import get_pydevd_file
            self.assertEqual(pydev_monkey.patch_args(check), [
                'C:\\bin\\python.exe',
                get_pydevd_file(),
                '--port',
                '0',
                '--client',
                '127.0.0.1',
                '--file',
                'connect(\\"127.0.0.1\\")'])
        finally:
            SetupHolder.setup = original
Esempio n. 28
0
    def test_monkey_patch_args_indc(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {'client': '127.0.0.1', 'port': '0'}
            check = ['C:\\bin\\python.exe', '-u', '-c', 'connect("127.0.0.1")']
            debug_command = (
                'import sys; sys.path.append(r\'%s\'); import pydevd; '
                'pydevd.settrace(host=\'127.0.0.1\', port=0, suspend=False, trace_only_current_thread=False, patch_multiprocessing=True); '
                'from pydevd import SetupHolder; SetupHolder.setup = %s; '
                'connect("127.0.0.1")') % (pydev_src_dir, SetupHolder.setup)
            if sys.platform == "win32":
                debug_command = debug_command.replace('"', '\\"')
                debug_command = '"%s"' % debug_command
            res = pydev_monkey.patch_args(check)
            self.assertEqual(
                res, ['C:\\bin\\python.exe', '-u', '-c', debug_command])
        finally:
            SetupHolder.setup = original
Esempio n. 29
0
    def test_monkey_patch_args_indc(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {"client": "127.0.0.1", "port": "0"}
            check = ["C:\\bin\\python.exe", "-u", "-c", 'connect("127.0.0.1")']
            debug_command = (
                "import sys; sys.path.append(r'%s'); import pydevd; "
                "pydevd.settrace(host='127.0.0.1', port=0, suspend=False, trace_only_current_thread=False, patch_multiprocessing=True); "
                ""
                'connect("127.0.0.1")'
            ) % pydev_src_dir
            if sys.platform == "win32":
                debug_command = debug_command.replace('"', '\\"')
                debug_command = '"%s"' % debug_command
            res = pydev_monkey.patch_args(check)
            self.assertEqual(res, ["C:\\bin\\python.exe", "-u", "-c", debug_command])
        finally:
            SetupHolder.setup = original
    def test_monkey_patch_args_indc(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {'client':'127.0.0.1', 'port': '0'}
            check=['C:\\bin\\python.exe', '-u', '-c', 'connect(\\"127.0.0.1\\")']
            sys.original_argv = []
            self.assertEqual(pydev_monkey.patch_args(check), [
                'C:\\bin\\python.exe',
                '-u',
                '-c',
                (
                    'import sys; sys.path.append(r\'%s\'); import pydevd; '
                    'pydevd.settrace(host=\'127.0.0.1\', port=0, suspend=False, trace_only_current_thread=False, patch_multiprocessing=True); '
                    'connect(\\"127.0.0.1\\")'
                ) % pydev_src_dir
            ])
        finally:
            SetupHolder.setup = original
Esempio n. 31
0
    def test_monkey_patch_args_no_indc_without_pydevd(self):
        original = SetupHolder.setup
        from _pydevd_bundle.pydevd_command_line_handling import get_pydevd_file

        try:
            SetupHolder.setup = {'client': '127.0.0.1', 'port': '0'}
            check = ['C:\\bin\\python.exe', 'target.py', 'connect(\\"127.0.0.1\\")', 'bar']
            self.assertEqual(pydev_monkey.patch_args(check), [
                'C:\\bin\\python.exe',
                get_pydevd_file(),
                '--port',
                '0',
                '--client',
                '127.0.0.1',
                '--file',
                'target.py',
                '"connect(\\\\\\"127.0.0.1\\\\\\")"' if sys.platform == 'win32' else 'connect(\\"127.0.0.1\\")',
                'bar',
            ])
        finally:
            SetupHolder.setup = original
Esempio n. 32
0
    def test_monkey_patch_args_module(self):
        original = SetupHolder.setup

        try:
            SetupHolder.setup = {'client': '127.0.0.1', 'port': '0', 'multiprocess': True}
            check = ['C:\\bin\\python.exe', '-m', 'test']
            from _pydevd_bundle.pydevd_command_line_handling import get_pydevd_file
            self.assertEqual(pydev_monkey.patch_args(check), [
                'C:\\bin\\python.exe',
                get_pydevd_file(),
                '--module',
                '--port',
                '0',
                '--client',
                '127.0.0.1',
                '--multiprocess',
                '--file',
                'test',
            ])
        finally:
            SetupHolder.setup = original
Esempio n. 33
0
def test_monkey_patch_args_module_subprocess_pathlib():
    try:
        import pathlib
    except ImportError:
        pytest.skip('pathlib not available.')

    original = SetupHolder.setup

    try:
        SetupHolder.setup = {
            'client': '127.0.0.1',
            'port': '0',
            'multiprocess': True
        }
        if sys.platform == 'win32':
            python_path = 'C:\\bin\\python.exe'
        else:
            python_path = '/bin/python'
        check = [pathlib.Path(python_path), '-mtest', pathlib.Path('bar')]
        from _pydevd_bundle.pydevd_command_line_handling import get_pydevd_file
        assert pydev_monkey.patch_args(check) == [
            python_path,
            get_pydevd_file(),
            '--module',
            '--port',
            '0',
            '--ppid',
            str(os.getpid()),
            '--client',
            '127.0.0.1',
            '--multiprocess',
            '--protocol-quoted-line',
            '--file',
            'test',
            'bar',
        ]
    finally:
        SetupHolder.setup = original
Esempio n. 34
0
    def test_monkey_patch_c_program_arg(self):
        original = SetupHolder.setup
        from _pydevd_bundle.pydevd_command_line_handling import get_pydevd_file

        try:
            SetupHolder.setup = {'client': '127.0.0.1', 'port': '0'}
            check = ['C:\\bin\\python.exe', '-u', 'target.py', '-c', '-another_arg']

            self.assertEqual(pydev_monkey.patch_args(check), [
                'C:\\bin\\python.exe',
                '-u',
                get_pydevd_file(),
                '--port',
                '0',
                '--client',
                '127.0.0.1',
                '--file',
                'target.py',
                '-c',
                '-another_arg'
            ])
        finally:
            SetupHolder.setup = original
Esempio n. 35
0
def test_monkey_patch_return_original_args():
    check = ['echo', '"my"', '"args"']
    res = pydev_monkey.patch_args(check[:])
    assert res == check
Esempio n. 36
0
def test_monkey_patch_wrong_object_type():
    check = [1, 22, '"my"', '"args"']
    res = pydev_monkey.patch_args(check[:])
    assert res == check
Esempio n. 37
0
def test_monkey_patch_wrong_object_type_2():
    check = ['C:\\bin\\python.exe', '-u', 1, '-qcconnect("127.0.0.1")']
    res = pydev_monkey.patch_args(check[:])
    assert res == check