ITADN

chown: changing ownership of '/tmp/pytest.../.../mysqldata...': Operation not permitted

#652ClosedMagicrafter13 创建于 2025-04-23
M
Magicrafter13commented
While there is a warning about mariadb/mysql stuff that doesn't appear to be the issue. Not sure what I'm doing wrong (if anything). Here's the basic test script: ```py import os import pytest @pytest.fixture def flask_app(mysql): os.environ['MYSQL_HOST'] = mysql.host os.environ['MYSQL_PORT'] = str(mysql.port) os.environ['MYSQL_USER'] = mysql.user os.environ['MYSQL_PASSWORD'] = mysql.password os.environ['MYSQL_DATABASE'] = mysql.db from app import app return app def test_home_route(flask_app): response = flask_app.get('/') assert response.status_code == 200 ``` And here's the error when running `pytest -q`: ```pytest E [100%] ========================================================================================================================== ERRORS ========================================================================================================================== ____________________________________________________________________________________________________________ ERROR at setup of test_home_route _____________________________________________________________________________________________________________ request = <SubRequest 'mysql' for <Function test_home_route>> @pytest.fixture def mysql_fixture( request: FixtureRequest, ) -> Generator[Connection, None, None]: """Client fixture for MySQL server. #. Get config. #. Try to import MySQLdb package. #. Connect to mysql server. #. Create database. #. Use proper database. #. Drop database after tests. :param request: fixture request object :returns: connection to database """ config = get_config(request) > process: Union[NoopMySQLExecutor, MySQLExecutor] = request.getfixturevalue( process_fixture_name ) venv/lib/python3.13/site-packages/pytest_mysql/factories/client.py:94: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ venv/lib/python3.13/site-packages/pytest_mysql/factories/process.py:138: in mysql_proc_fixture with mysql_executor: venv/lib/python3.13/site-packages/mirakuru/base.py:180: in __enter__ return self.start() venv/lib/python3.13/site-packages/pytest_mysql/executor.py:146: in start self.initialise_mysql_db_install() venv/lib/python3.13/site-packages/pytest_mysql/executor.py:134: in initialise_mysql_db_install subprocess.check_output(init_command, shell=True) /usr/lib/python3.13/subprocess.py:472: in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ input = None, capture_output = False, timeout = None, check = True popenargs = ('mysql_install_db --user=root --datadir=/tmp/pytest-of-matthew/pytest-0/pytest-mysql-mysql_proc0/mysqldata_31602 --tmpdir=/tmp/pytest-of-matthew/pytest-0/pytest-mysql-mysql_proc0',), kwargs = {'shell': True, 'stdout': -1} process = <Popen: returncode: 1 args: 'mysql_install_db --user=root --datadir=/tmp/pyt...>, stdout = b"Cannot change ownership of the database directories to the 'root'\nuser. Check that you have the necessary permissions and try again.\n" stderr = None, retcode = 1 def run(*popenargs, input=None, capture_output=False, timeout=None, check=False, **kwargs): """Run command with arguments and return a CompletedProcess instance. The returned instance will have attributes args, returncode, stdout and stderr. By default, stdout and stderr are not captured, and those attributes will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them, or pass capture_output=True to capture both. If check is True and the exit code was non-zero, it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute, and output & stderr attributes if those streams were captured. If timeout (seconds) is given and the process takes too long, a TimeoutExpired exception will be raised. There is an optional argument "input", allowing you to pass bytes or a string to the subprocess's stdin. If you use this argument you may not also use the Popen constructor's "stdin" argument, as it will be used internally. By default, all communication is in bytes, and therefore any "input" should be bytes, and the stdout and stderr will be bytes. If in text mode, any "input" should be a string, and stdout and stderr will be strings decoded according to locale encoding, or by "encoding" if set. Text mode is triggered by setting any of text, encoding, errors or universal_newlines. The other arguments are the same as for the Popen constructor. """ if input is not None: if kwargs.get('stdin') is not None: raise ValueError('stdin and input arguments may not both be used.') kwargs['stdin'] = PIPE if capture_output: if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None: raise ValueError('stdout and stderr arguments may not be used ' 'with capture_output.') kwargs['stdout'] = PIPE kwargs['stderr'] = PIPE with Popen(*popenargs, **kwargs) as process: try: stdout, stderr = process.communicate(input, timeout=timeout) except TimeoutExpired as exc: process.kill() if _mswindows: # Windows accumulates the output in a single blocking # read() call run on child threads, with the timeout # being done in a join() on those threads. communicate() # _after_ kill() is required to collect that and add it # to the exception. exc.stdout, exc.stderr = process.communicate() else: # POSIX _communicate already populated the output so # far into the TimeoutExpired exception. process.wait() raise except: # Including KeyboardInterrupt, communicate handled that. process.kill() # We don't call process.wait() as .__exit__ does that for us. raise retcode = process.poll() if check and retcode: > raise CalledProcessError(retcode, process.args, output=stdout, stderr=stderr) E subprocess.CalledProcessError: Command 'mysql_install_db --user=root --datadir=/tmp/pytest-of-matthew/pytest-0/pytest-mysql-mysql_proc0/mysqldata_31602 --tmpdir=/tmp/pytest-of-matthew/pytest-0/pytest-mysql-mysql_proc0' returned non-zero exit status 1. /usr/lib/python3.13/subprocess.py:577: CalledProcessError ------------------------------------------------------------------------------------------------------------------ Captured stderr setup ------------------------------------------------------------------------------------------------------------------- mysqld: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadbd' instead /usr/bin/mysql_install_db: Deprecated program name. It will be removed in a future release, use 'mariadb-install-db' instead chown: changing ownership of '/tmp/pytest-of-matthew/pytest-0/pytest-mysql-mysql_proc0/mysqldata_31602': Operation not permitted ================================================================================================================= short test summary info ================================================================================================================== ERROR tests/test_app.py::test_home_route - subprocess.CalledProcessError: Command 'mysql_install_db --user=root --datadir=/tmp/pytest-of-matthew/pytest-0/pytest-mysql-mysql_proc0/mysqldata_31602 --tmpdir=/tmp/pytest-of-matthew/pytest-0/pytest-mysql-mysql_proc0' returned non-zero exit statu... 1 error in 0.09s ```
关闭于 2025-06-05 3 条评论