Erotemic / ubelt

A Python utility library with a stdlib like feel and extra batteries. Paths, Progress, Dicts, Downloads, Caching, Hashing: ubelt makes it easy!
Apache License 2.0
719 stars 43 forks source link

23 errors in tests #127

Closed yurivict closed 1 year ago

yurivict commented 2 years ago

Describe the bug

=========================================================================================== ERRORS ===========================================================================================
__________________________________________________________________________ ERROR at setup of test_download_no_fpath __________________________________________________________________________

module = <module 'test_download' from '/disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/ubelt-1.2.1/tests/test_download.py'>

    def setup_module(module):
        """ setup any state specific to the execution of the given module."""
>       SingletonTestServer.instance()

tests/test_download.py:664: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_download.py:419: in instance
    self = cls()
tests/test_download.py:463: in __init__
    info = ub.cmd(server_cmd, detach=True, cwd=dpath)
ubelt/util_cmd.py:290: in cmd
    info = {'proc': make_proc(), 'command': command_text}
ubelt/util_cmd.py:276: in make_proc
    proc = subprocess.Popen(args, stdout=subprocess.PIPE,
/usr/local/lib/python3.9/subprocess.py:951: in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Popen: returncode: 255 args: ['python', '-m', 'http.server', '43123']>, args = ['python', '-m', 'http.server', '43123'], executable = b'python', preexec_fn = None, close_fds = True
pass_fds = (), cwd = '/disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/.cache/ubelt/tests/test_download/simple_server', env = None, startupinfo = None, creationflags = 0, shell = False
p2cread = -1, p2cwrite = -1, c2pread = 11, c2pwrite = 12, errread = 13, errwrite = 14, restore_signals = True, gid = None, gids = None, uid = None, umask = -1, start_new_session = False

    def _execute_child(self, args, executable, preexec_fn, close_fds,
                       pass_fds, cwd, env,
                       startupinfo, creationflags, shell,
                       p2cread, p2cwrite,
                       c2pread, c2pwrite,
                       errread, errwrite,
                       restore_signals,
                       gid, gids, uid, umask,
                       start_new_session):
        """Execute program (POSIX version)"""

        if isinstance(args, (str, bytes)):
            args = [args]
        elif isinstance(args, os.PathLike):
            if shell:
                raise TypeError('path-like args is not allowed when '
                                'shell is true')
            args = [args]
        else:
            args = list(args)

        if shell:
            # On Android the default shell is at '/system/bin/sh'.
            unix_shell = ('/system/bin/sh' if
                      hasattr(sys, 'getandroidapilevel') else '/bin/sh')
            args = [unix_shell, "-c"] + args
            if executable:
                args[0] = executable

        if executable is None:
            executable = args[0]

        sys.audit("subprocess.Popen", executable, args, cwd, env)

        if (_USE_POSIX_SPAWN
                and os.path.dirname(executable)
                and preexec_fn is None
                and not close_fds
                and not pass_fds
                and cwd is None
                and (p2cread == -1 or p2cread > 2)
                and (c2pwrite == -1 or c2pwrite > 2)
                and (errwrite == -1 or errwrite > 2)
                and not start_new_session
                and gid is None
                and gids is None
                and uid is None
                and umask < 0):
            self._posix_spawn(args, executable, env, restore_signals,
                              p2cread, p2cwrite,
                              c2pread, c2pwrite,
                              errread, errwrite)
            return

        orig_executable = executable

        # For transferring possible exec failure from child to parent.
        # Data format: "exception name:hex errno:description"
        # Pickle is not used; it is complex and involves memory allocation.
        errpipe_read, errpipe_write = os.pipe()
        # errpipe_write must not be in the standard io 0, 1, or 2 fd range.
        low_fds_to_close = []
        while errpipe_write < 3:
            low_fds_to_close.append(errpipe_write)
            errpipe_write = os.dup(errpipe_write)
        for low_fd in low_fds_to_close:
            os.close(low_fd)
        try:
            try:
                # We must avoid complex work that could involve
                # malloc or free in the child process to avoid
                # potential deadlocks, thus we do all this here.
                # and pass it to fork_exec()

                if env is not None:
                    env_list = []
                    for k, v in env.items():
                        k = os.fsencode(k)
                        if b'=' in k:
                            raise ValueError("illegal environment variable name")
                        env_list.append(k + b'=' + os.fsencode(v))
                else:
                    env_list = None  # Use execv instead of execve.
                executable = os.fsencode(executable)
                if os.path.dirname(executable):
                    executable_list = (executable,)
                else:
                    # This matches the behavior of os._execvpe().
                    executable_list = tuple(
                        os.path.join(os.fsencode(dir), executable)
                        for dir in os.get_exec_path(env))
                fds_to_keep = set(pass_fds)
                fds_to_keep.add(errpipe_write)
                self.pid = _posixsubprocess.fork_exec(
                        args, executable_list,
                        close_fds, tuple(sorted(map(int, fds_to_keep))),
                        cwd, env_list,
                        p2cread, p2cwrite, c2pread, c2pwrite,
                        errread, errwrite,
                        errpipe_read, errpipe_write,
                        restore_signals, start_new_session,
                        gid, gids, uid, umask,
                        preexec_fn)
                self._child_created = True
            finally:
                # be sure the FD is closed no matter what
                os.close(errpipe_write)

            self._close_pipe_fds(p2cread, p2cwrite,
                                 c2pread, c2pwrite,
                                 errread, errwrite)

            # Wait for exec to fail or succeed; possibly raising an
            # exception (limited in size)
            errpipe_data = bytearray()
            while True:
                part = os.read(errpipe_read, 50000)
                errpipe_data += part
                if not part or len(errpipe_data) > 50000:
                    break
        finally:
            # be sure the FD is closed no matter what
            os.close(errpipe_read)

        if errpipe_data:
            try:
                pid, sts = os.waitpid(self.pid, 0)
                if pid == self.pid:
                    self._handle_exitstatus(sts)
                else:
                    self.returncode = sys.maxsize
            except ChildProcessError:
                pass

            try:
                exception_name, hex_errno, err_msg = (
                        errpipe_data.split(b':', 2))
                # The encoding here should match the encoding
                # written in by the subprocess implementations
                # like _posixsubprocess
                err_msg = err_msg.decode()
            except ValueError:
                exception_name = b'SubprocessError'
                hex_errno = b'0'
                err_msg = 'Bad exception data from child: {!r}'.format(
                              bytes(errpipe_data))
            child_exception_type = getattr(
                    builtins, exception_name.decode('ascii'),
                    SubprocessError)
            if issubclass(child_exception_type, OSError) and hex_errno:
                errno_num = int(hex_errno, 16)
                child_exec_never_called = (err_msg == "noexec")
                if child_exec_never_called:
                    err_msg = ""
                    # The error must be from chdir(cwd).
                    err_filename = cwd
                else:
                    err_filename = orig_executable
                if errno_num != 0:
                    err_msg = os.strerror(errno_num)
>               raise child_exception_type(errno_num, err_msg, err_filename)
E               FileNotFoundError: [Errno 2] No such file or directory: 'python'

/usr/local/lib/python3.9/subprocess.py:1821: FileNotFoundError
----------------------------------------------------------------------------------- Captured stdout setup ------------------------------------------------------------------------------------
port = 43123
_________________________________________________________________________ ERROR at setup of test_download_with_fpath _________________________________________________________________________

module = <module 'test_download' from '/disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/ubelt-1.2.1/tests/test_download.py'>

    def setup_module(module):
        """ setup any state specific to the execution of the given module."""
>       SingletonTestServer.instance()

tests/test_download.py:664: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_download.py:419: in instance
    self = cls()
tests/test_download.py:463: in __init__
    info = ub.cmd(server_cmd, detach=True, cwd=dpath)
ubelt/util_cmd.py:290: in cmd
    info = {'proc': make_proc(), 'command': command_text}
ubelt/util_cmd.py:276: in make_proc
    proc = subprocess.Popen(args, stdout=subprocess.PIPE,
/usr/local/lib/python3.9/subprocess.py:951: in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Popen: returncode: 255 args: ['python', '-m', 'http.server', '43123']>, args = ['python', '-m', 'http.server', '43123'], executable = b'python', preexec_fn = None, close_fds = True
pass_fds = (), cwd = '/disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/.cache/ubelt/tests/test_download/simple_server', env = None, startupinfo = None, creationflags = 0, shell = False
p2cread = -1, p2cwrite = -1, c2pread = 11, c2pwrite = 12, errread = 13, errwrite = 14, restore_signals = True, gid = None, gids = None, uid = None, umask = -1, start_new_session = False

    def _execute_child(self, args, executable, preexec_fn, close_fds,
                       pass_fds, cwd, env,
                       startupinfo, creationflags, shell,
                       p2cread, p2cwrite,
                       c2pread, c2pwrite,
                       errread, errwrite,
                       restore_signals,
                       gid, gids, uid, umask,
                       start_new_session):
        """Execute program (POSIX version)"""

        if isinstance(args, (str, bytes)):
            args = [args]
        elif isinstance(args, os.PathLike):
            if shell:
                raise TypeError('path-like args is not allowed when '
                                'shell is true')
            args = [args]
        else:
            args = list(args)

        if shell:
            # On Android the default shell is at '/system/bin/sh'.
            unix_shell = ('/system/bin/sh' if
                      hasattr(sys, 'getandroidapilevel') else '/bin/sh')
            args = [unix_shell, "-c"] + args
            if executable:
                args[0] = executable

        if executable is None:
            executable = args[0]

        sys.audit("subprocess.Popen", executable, args, cwd, env)

        if (_USE_POSIX_SPAWN
                and os.path.dirname(executable)
                and preexec_fn is None
                and not close_fds
                and not pass_fds
                and cwd is None
                and (p2cread == -1 or p2cread > 2)
                and (c2pwrite == -1 or c2pwrite > 2)
                and (errwrite == -1 or errwrite > 2)
                and not start_new_session
                and gid is None
                and gids is None
                and uid is None
                and umask < 0):
            self._posix_spawn(args, executable, env, restore_signals,
                              p2cread, p2cwrite,
                              c2pread, c2pwrite,
                              errread, errwrite)
            return

        orig_executable = executable

        # For transferring possible exec failure from child to parent.
        # Data format: "exception name:hex errno:description"
        # Pickle is not used; it is complex and involves memory allocation.
        errpipe_read, errpipe_write = os.pipe()
        # errpipe_write must not be in the standard io 0, 1, or 2 fd range.
        low_fds_to_close = []
        while errpipe_write < 3:
            low_fds_to_close.append(errpipe_write)
            errpipe_write = os.dup(errpipe_write)
        for low_fd in low_fds_to_close:
            os.close(low_fd)
        try:
            try:
                # We must avoid complex work that could involve
                # malloc or free in the child process to avoid
                # potential deadlocks, thus we do all this here.
                # and pass it to fork_exec()

                if env is not None:
                    env_list = []
                    for k, v in env.items():
                        k = os.fsencode(k)
                        if b'=' in k:
                            raise ValueError("illegal environment variable name")
                        env_list.append(k + b'=' + os.fsencode(v))
                else:
                    env_list = None  # Use execv instead of execve.
                executable = os.fsencode(executable)
                if os.path.dirname(executable):
                    executable_list = (executable,)
                else:
                    # This matches the behavior of os._execvpe().
                    executable_list = tuple(
                        os.path.join(os.fsencode(dir), executable)
                        for dir in os.get_exec_path(env))
                fds_to_keep = set(pass_fds)
                fds_to_keep.add(errpipe_write)
                self.pid = _posixsubprocess.fork_exec(
                        args, executable_list,
                        close_fds, tuple(sorted(map(int, fds_to_keep))),
                        cwd, env_list,
                        p2cread, p2cwrite, c2pread, c2pwrite,
                        errread, errwrite,
                        errpipe_read, errpipe_write,
                        restore_signals, start_new_session,
                        gid, gids, uid, umask,
                        preexec_fn)
                self._child_created = True
            finally:
                # be sure the FD is closed no matter what
                os.close(errpipe_write)

            self._close_pipe_fds(p2cread, p2cwrite,
                                 c2pread, c2pwrite,
                                 errread, errwrite)

            # Wait for exec to fail or succeed; possibly raising an
            # exception (limited in size)
            errpipe_data = bytearray()
            while True:
                part = os.read(errpipe_read, 50000)
                errpipe_data += part
                if not part or len(errpipe_data) > 50000:
                    break
        finally:
            # be sure the FD is closed no matter what
            os.close(errpipe_read)

        if errpipe_data:
            try:
                pid, sts = os.waitpid(self.pid, 0)
                if pid == self.pid:
                    self._handle_exitstatus(sts)
                else:
                    self.returncode = sys.maxsize
            except ChildProcessError:
                pass

            try:
                exception_name, hex_errno, err_msg = (
                        errpipe_data.split(b':', 2))
                # The encoding here should match the encoding
                # written in by the subprocess implementations
                # like _posixsubprocess
                err_msg = err_msg.decode()
            except ValueError:
                exception_name = b'SubprocessError'
                hex_errno = b'0'
                err_msg = 'Bad exception data from child: {!r}'.format(
                              bytes(errpipe_data))
            child_exception_type = getattr(
                    builtins, exception_name.decode('ascii'),
                    SubprocessError)
            if issubclass(child_exception_type, OSError) and hex_errno:
                errno_num = int(hex_errno, 16)
                child_exec_never_called = (err_msg == "noexec")
                if child_exec_never_called:
                    err_msg = ""
                    # The error must be from chdir(cwd).
                    err_filename = cwd
                else:
                    err_filename = orig_executable
                if errno_num != 0:
                    err_msg = os.strerror(errno_num)
>               raise child_exception_type(errno_num, err_msg, err_filename)
E               FileNotFoundError: [Errno 2] No such file or directory: 'python'

/usr/local/lib/python3.9/subprocess.py:1821: FileNotFoundError
_________________________________________________________________________ ERROR at setup of test_download_chunksize __________________________________________________________________________

module = <module 'test_download' from '/disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/ubelt-1.2.1/tests/test_download.py'>

    def setup_module(module):
        """ setup any state specific to the execution of the given module."""
>       SingletonTestServer.instance()

tests/test_download.py:664: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_download.py:419: in instance
    self = cls()
tests/test_download.py:463: in __init__
    info = ub.cmd(server_cmd, detach=True, cwd=dpath)
ubelt/util_cmd.py:290: in cmd
    info = {'proc': make_proc(), 'command': command_text}
ubelt/util_cmd.py:276: in make_proc
    proc = subprocess.Popen(args, stdout=subprocess.PIPE,
/usr/local/lib/python3.9/subprocess.py:951: in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Popen: returncode: 255 args: ['python', '-m', 'http.server', '43123']>, args = ['python', '-m', 'http.server', '43123'], executable = b'python', preexec_fn = None, close_fds = True
pass_fds = (), cwd = '/disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/.cache/ubelt/tests/test_download/simple_server', env = None, startupinfo = None, creationflags = 0, shell = False
p2cread = -1, p2cwrite = -1, c2pread = 11, c2pwrite = 12, errread = 13, errwrite = 14, restore_signals = True, gid = None, gids = None, uid = None, umask = -1, start_new_session = False

    def _execute_child(self, args, executable, preexec_fn, close_fds,
                       pass_fds, cwd, env,
                       startupinfo, creationflags, shell,
                       p2cread, p2cwrite,
                       c2pread, c2pwrite,
                       errread, errwrite,
                       restore_signals,
                       gid, gids, uid, umask,
                       start_new_session):
        """Execute program (POSIX version)"""

        if isinstance(args, (str, bytes)):
            args = [args]
        elif isinstance(args, os.PathLike):
            if shell:
                raise TypeError('path-like args is not allowed when '
                                'shell is true')
            args = [args]
        else:
            args = list(args)

        if shell:
            # On Android the default shell is at '/system/bin/sh'.
            unix_shell = ('/system/bin/sh' if
                      hasattr(sys, 'getandroidapilevel') else '/bin/sh')
            args = [unix_shell, "-c"] + args
            if executable:
                args[0] = executable

        if executable is None:
            executable = args[0]

        sys.audit("subprocess.Popen", executable, args, cwd, env)

        if (_USE_POSIX_SPAWN
                and os.path.dirname(executable)
                and preexec_fn is None
                and not close_fds
                and not pass_fds
                and cwd is None
                and (p2cread == -1 or p2cread > 2)
                and (c2pwrite == -1 or c2pwrite > 2)
                and (errwrite == -1 or errwrite > 2)
                and not start_new_session
                and gid is None
                and gids is None
                and uid is None
                and umask < 0):
            self._posix_spawn(args, executable, env, restore_signals,
                              p2cread, p2cwrite,
                              c2pread, c2pwrite,
                              errread, errwrite)
            return

        orig_executable = executable

        # For transferring possible exec failure from child to parent.
        # Data format: "exception name:hex errno:description"
        # Pickle is not used; it is complex and involves memory allocation.
        errpipe_read, errpipe_write = os.pipe()
        # errpipe_write must not be in the standard io 0, 1, or 2 fd range.
        low_fds_to_close = []
        while errpipe_write < 3:
            low_fds_to_close.append(errpipe_write)
            errpipe_write = os.dup(errpipe_write)
        for low_fd in low_fds_to_close:
            os.close(low_fd)
        try:
            try:
                # We must avoid complex work that could involve
                # malloc or free in the child process to avoid
                # potential deadlocks, thus we do all this here.
                # and pass it to fork_exec()

                if env is not None:
                    env_list = []
                    for k, v in env.items():
                        k = os.fsencode(k)
                        if b'=' in k:
                            raise ValueError("illegal environment variable name")
                        env_list.append(k + b'=' + os.fsencode(v))
                else:
                    env_list = None  # Use execv instead of execve.
                executable = os.fsencode(executable)
                if os.path.dirname(executable):
                    executable_list = (executable,)
                else:
                    # This matches the behavior of os._execvpe().
                    executable_list = tuple(
                        os.path.join(os.fsencode(dir), executable)
                        for dir in os.get_exec_path(env))
                fds_to_keep = set(pass_fds)
                fds_to_keep.add(errpipe_write)
                self.pid = _posixsubprocess.fork_exec(
                        args, executable_list,
                        close_fds, tuple(sorted(map(int, fds_to_keep))),
                        cwd, env_list,
                        p2cread, p2cwrite, c2pread, c2pwrite,
                        errread, errwrite,
                        errpipe_read, errpipe_write,
                        restore_signals, start_new_session,
                        gid, gids, uid, umask,
                        preexec_fn)
                self._child_created = True
            finally:
                # be sure the FD is closed no matter what
                os.close(errpipe_write)

            self._close_pipe_fds(p2cread, p2cwrite,
                                 c2pread, c2pwrite,
                                 errread, errwrite)

            # Wait for exec to fail or succeed; possibly raising an
            # exception (limited in size)
            errpipe_data = bytearray()
            while True:
                part = os.read(errpipe_read, 50000)
                errpipe_data += part
                if not part or len(errpipe_data) > 50000:
                    break
        finally:
            # be sure the FD is closed no matter what
            os.close(errpipe_read)

        if errpipe_data:
            try:
                pid, sts = os.waitpid(self.pid, 0)
                if pid == self.pid:
                    self._handle_exitstatus(sts)
                else:
                    self.returncode = sys.maxsize
            except ChildProcessError:
                pass

            try:
                exception_name, hex_errno, err_msg = (
                        errpipe_data.split(b':', 2))
                # The encoding here should match the encoding
                # written in by the subprocess implementations
                # like _posixsubprocess
                err_msg = err_msg.decode()
            except ValueError:
                exception_name = b'SubprocessError'
                hex_errno = b'0'
                err_msg = 'Bad exception data from child: {!r}'.format(
                              bytes(errpipe_data))
            child_exception_type = getattr(
                    builtins, exception_name.decode('ascii'),
                    SubprocessError)
            if issubclass(child_exception_type, OSError) and hex_errno:
                errno_num = int(hex_errno, 16)
                child_exec_never_called = (err_msg == "noexec")
                if child_exec_never_called:
                    err_msg = ""
                    # The error must be from chdir(cwd).
                    err_filename = cwd
                else:
                    err_filename = orig_executable
                if errno_num != 0:
                    err_msg = os.strerror(errno_num)
>               raise child_exception_type(errno_num, err_msg, err_filename)
E               FileNotFoundError: [Errno 2] No such file or directory: 'python'

/usr/local/lib/python3.9/subprocess.py:1821: FileNotFoundError
_______________________________________________________________________ ERROR at setup of test_download_cover_hashers ________________________________________________________________________

module = <module 'test_download' from '/disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/ubelt-1.2.1/tests/test_download.py'>

    def setup_module(module):
        """ setup any state specific to the execution of the given module."""
>       SingletonTestServer.instance()

tests/test_download.py:664: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_download.py:419: in instance
    self = cls()
tests/test_download.py:463: in __init__
    info = ub.cmd(server_cmd, detach=True, cwd=dpath)
ubelt/util_cmd.py:290: in cmd
    info = {'proc': make_proc(), 'command': command_text}
ubelt/util_cmd.py:276: in make_proc
    proc = subprocess.Popen(args, stdout=subprocess.PIPE,
/usr/local/lib/python3.9/subprocess.py:951: in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <Popen: returncode: 255 args: ['python', '-m', 'http.server', '43123']>, args = ['python', '-m', 'http.server', '43123'], executable = b'python', preexec_fn = None, close_fds = True
pass_fds = (), cwd = '/disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/.cache/ubelt/tests/test_download/simple_server', env = None, startupinfo = None, creationflags = 0, shell = False
p2cread = -1, p2cwrite = -1, c2pread = 11, c2pwrite = 12, errread = 13, errwrite = 14, restore_signals = True, gid = None, gids = None, uid = None, umask = -1, start_new_session = False

    def _execute_child(self, args, executable, preexec_fn, close_fds,
                       pass_fds, cwd, env,
                       startupinfo, creationflags, shell,
                       p2cread, p2cwrite,
                       c2pread, c2pwrite,
                       errread, errwrite,
                       restore_signals,
                       gid, gids, uid, umask,
                       start_new_session):
        """Execute program (POSIX version)"""

        if isinstance(args, (str, bytes)):
            args = [args]
        elif isinstance(args, os.PathLike):
            if shell:
                raise TypeError('path-like args is not allowed when '
                                'shell is true')
            args = [args]
        else:
            args = list(args)

        if shell:
            # On Android the default shell is at '/system/bin/sh'.
            unix_shell = ('/system/bin/sh' if
                      hasattr(sys, 'getandroidapilevel') else '/bin/sh')
            args = [unix_shell, "-c"] + args
            if executable:
                args[0] = executable

        if executable is None:
            executable = args[0]

        sys.audit("subprocess.Popen", executable, args, cwd, env)

        if (_USE_POSIX_SPAWN
                and os.path.dirname(executable)
                and preexec_fn is None
                and not close_fds
                and not pass_fds
                and cwd is None
                and (p2cread == -1 or p2cread > 2)
                and (c2pwrite == -1 or c2pwrite > 2)
                and (errwrite == -1 or errwrite > 2)
                and not start_new_session
                and gid is None
                and gids is None
                and uid is None
                and umask < 0):
            self._posix_spawn(args, executable, env, restore_signals,
                              p2cread, p2cwrite,
                              c2pread, c2pwrite,
                              errread, errwrite)
            return

        orig_executable = executable

        # For transferring possible exec failure from child to parent.
        # Data format: "exception name:hex errno:description"
        # Pickle is not used; it is complex and involves memory allocation.
        errpipe_read, errpipe_write = os.pipe()
        # errpipe_write must not be in the standard io 0, 1, or 2 fd range.
        low_fds_to_close = []
        while errpipe_write < 3:

Expected behavior A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

Erotemic commented 2 years ago

The tests are assuming the existence of an executable named "python" in the PATH. Perhaps it would be better to use sys.executable. I seem to remember there was a reason I didn't do that in the first place, but I could also be imagining that.

I suppose there could also be a pre-test hook that checks to see if python does exist on the PATH, and perhaps it checks the version, and maybe tries python3 if python doesn't work.

I'm assuming you only have python3 on your system, and you aren't in a virtual environment? Can you check that if you you make a symlink python -> python3 if it works? Alternatively, can you try in a virtual environment?

I'm also not super worried about the singleton test server tests failing. The idea is to provide a local URL so the download tests don't need to rely on a network existing (which also makes them much faster). If they are causing issues even after the above test, then perhaps we just disable those on FreeBSD?

yurivict commented 2 years ago

Indeed, the failures are gone with the python symlink.

Erotemic commented 2 years ago

That's good to know. None of the library functions should depend on that, so you can remove that symlink and still expect the library to work. A fix to the test like I mentioned above should be a better more robust fix. If you feel like making a PR, I'd welcome the help, otherwise I'll get to it eventually.

yurivict commented 2 years ago

I added the symlink to the FreeBSD port that exists only for the duration of build/test.

yurivict commented 2 years ago

The version 1.2.2 has 1 failure:

========================================================================================== FAILURES ==========================================================================================
______________________________________________________________________________ test_import_of_editable_install _______________________________________________________________________________

    def test_import_of_editable_install():
        _check_skip_editable_module_tests()
        import ubelt as ub
        for PROJ in GLOBAL_PROJECTS:
            result = ub.modname_to_modpath(PROJ.mod_name)
            print(f'result={result}')
>           assert result is not None
E           assert None is not None

tests/test_editable_modules.py:454: AssertionError
----------------------------------------------------------------------------------- Captured stdout setup ------------------------------------------------------------------------------------
┌─── START CMD ───
[ubelt.cmd] yuri@yv.noip.me:~/ubelt-1.2.2$ /usr/local/bin/python3.9 -m pip install -e /disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/.cache/ubelt/tests/demo_packages/purepy_src_demo_pkg_cpcivzce
Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/.cache/ubelt/tests/demo_packages/purepy_src_demo_pkg_cpcivzce
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Checking if build backend supports build_editable: started
  Checking if build backend supports build_editable: finished with status 'done'
  Getting requirements to build editable: started
  Getting requirements to build editable: finished with status 'done'
  Preparing editable metadata (pyproject.toml): started
  Preparing editable metadata (pyproject.toml): finished with status 'done'
Requirement already satisfied: packaging in /usr/local/lib/python3.9/site-packages (from purepy-src-demo-pkg-cpcivzce==1.0.0) (21.3)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/local/lib/python3.9/site-packages (from packaging->purepy-src-demo-pkg-cpcivzce==1.0.0) (3.0.9)
Building wheels for collected packages: purepy-src-demo-pkg-cpcivzce
  Building editable for purepy-src-demo-pkg-cpcivzce (pyproject.toml): started
  Building editable for purepy-src-demo-pkg-cpcivzce (pyproject.toml): finished with status 'done'
  Created wheel for purepy-src-demo-pkg-cpcivzce: filename=purepy_src_demo_pkg_cpcivzce-1.0.0-0.editable-py3-none-any.whl size=1535 sha256=210b373169bc01f6ae5f18406fc5f3c6d9fbd17f8752150b696d77cf7451e6cd
  Stored in directory: /tmp/pip-ephem-wheel-cache-jc9_pdjc/wheels/56/29/60/e07036ade44926c103a63b7bb54f3b1972295ed04bb0e24ab3
Successfully built purepy-src-demo-pkg-cpcivzce
Installing collected packages: purepy-src-demo-pkg-cpcivzce
Successfully installed purepy-src-demo-pkg-cpcivzce-1.0.0
└─── END CMD ───
┌─── START CMD ───
[ubelt.cmd] yuri@yv.noip.me:~/ubelt-1.2.2$ /usr/local/bin/python3.9 -m pip install -e /disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/.cache/ubelt/tests/demo_packages/purepy_root_demo_pkg_cpcivzce
Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///disk-samsung/freebsd-ports/devel/py-ubelt/work-py39/.cache/ubelt/tests/demo_packages/purepy_root_demo_pkg_cpcivzce
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Checking if build backend supports build_editable: started
  Checking if build backend supports build_editable: finished with status 'done'
  Getting requirements to build editable: started
  Getting requirements to build editable: finished with status 'done'
  Preparing editable metadata (pyproject.toml): started
  Preparing editable metadata (pyproject.toml): finished with status 'done'
Requirement already satisfied: packaging in /usr/local/lib/python3.9/site-packages (from purepy-root-demo-pkg-cpcivzce==1.0.0) (21.3)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/local/lib/python3.9/site-packages (from packaging->purepy-root-demo-pkg-cpcivzce==1.0.0) (3.0.9)
Building wheels for collected packages: purepy-root-demo-pkg-cpcivzce
  Building editable for purepy-root-demo-pkg-cpcivzce (pyproject.toml): started
  Building editable for purepy-root-demo-pkg-cpcivzce (pyproject.toml): finished with status 'done'
  Created wheel for purepy-root-demo-pkg-cpcivzce: filename=purepy_root_demo_pkg_cpcivzce-1.0.0-0.editable-py3-none-any.whl size=2715 sha256=1ac78260283967b6e6c430984edd6a276b2c9d4a97534e28ef795203869ed164
  Stored in directory: /tmp/pip-ephem-wheel-cache-fqnhpbnw/wheels/d6/c1/72/ae8b121c9f6825194b11714f1fb6fa8bd4e6eaedfe65900379
Successfully built purepy-root-demo-pkg-cpcivzce
Installing collected packages: purepy-root-demo-pkg-cpcivzce
Successfully installed purepy-root-demo-pkg-cpcivzce-1.0.0
└─── END CMD ───
----------------------------------------------------------------------------------- Captured stderr setup ------------------------------------------------------------------------------------
WARNING: Error parsing requirements for hatch-vcs: [Errno 2] No such file or directory: '/usr/local/lib/python3.9/site-packages/hatch_vcs-0.2.0.dist-info/METADATA'
WARNING: Error parsing requirements for hatch-vcs: [Errno 2] No such file or directory: '/usr/local/lib/python3.9/site-packages/hatch_vcs-0.2.0.dist-info/METADATA'
------------------------------------------------------------------------------------ Captured stdout call ------------------------------------------------------------------------------------
result=None
---------------------------------------------------------------------------------- Captured stdout teardown ----------------------------------------------------------------------------------
┌─── START CMD ───
[ubelt.cmd] yuri@yv.noip.me:~/ubelt-1.2.2$ /usr/local/bin/python3.9 -m pip uninstall purepy_src_demo_pkg_cpcivzce -y
Found existing installation: purepy-src-demo-pkg-cpcivzce 1.0.0
Uninstalling purepy-src-demo-pkg-cpcivzce-1.0.0:
  Successfully uninstalled purepy-src-demo-pkg-cpcivzce-1.0.0
└─── END CMD ───
┌─── START CMD ───
[ubelt.cmd] yuri@yv.noip.me:~/ubelt-1.2.2$ /usr/local/bin/python3.9 -m pip uninstall purepy_root_demo_pkg_cpcivzce -y
Found existing installation: purepy-root-demo-pkg-cpcivzce 1.0.0
Uninstalling purepy-root-demo-pkg-cpcivzce-1.0.0:
  Successfully uninstalled purepy-root-demo-pkg-cpcivzce-1.0.0
└─── END CMD ───
====================================================================================== warnings summary ======================================================================================
../../../../../../usr/local/lib/python3.9/site-packages/pytest_asyncio/plugin.py:191
  /usr/local/lib/python3.9/site-packages/pytest_asyncio/plugin.py:191: DeprecationWarning: The 'asyncio_mode' default value will change to 'strict' in future, please explicitly use 'asyncio_mode=strict' or 'asyncio_mode=auto' in pytest configuration file.
    config.issue_config_time_warning(LEGACY_MODE, stacklevel=2)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================== short test summary info ===================================================================================
SKIPPED [1] tests/test_download.py:256: This takes a long time to timeout and I dont understand why
SKIPPED [1] tests/test_futures.py:42: long test, demos that timeout does not work with SerialExecutor
SKIPPED [1] tests/test_hash.py:435: blake3 is not available
SKIPPED [1] tests/test_path.py:26: pathlib is not installed
==================================================================== 1 failed, 188 passed, 4 skipped, 1 warning in 43.01s ====================================================================

Python-3.9 FreeBSD 13.1