我试图从pytest-dbfixtures中使用mysql
。我有一个例子测试文件从文件:pytest mysql数据库夹具:无法创建数据库
def test_using_mysql(mysql):
mysql.query("SELECT CURRENT_USER()")
,当我通过$ py.test test_example.py
运行它,我得到这个错误:
E subprocess.CalledProcessError: Command '/usr/bin/mysql_install_db --user=Fluffy --datadir=/tmp/mysqldata_3307' returned non-zero exit status 127
/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py:711: CalledProcessError
------------------- Captured stderr setup ------
[ERROR] /bin/sh: /usr/bin/mysql_install_db: No such file or directory
我使用python 3.5和OS X 10.11.5。 MySQL 5.7.12通过homebrew
安装,运行良好。
homebrew
不会创建symlimks到/usr/bin
,只能到/usr/local/bin
。如果我手动创建的链接:
$ sudo ln -s /usr/local/Cellar/mysql/5.7.12/bin/mysql_install_db /usr/bin/mysql_install_db
我从pytest以下错误:
E subprocess.CalledProcessError: Command '/usr/bin/mysql_install_db --user=Fluffy --datadir=/tmp/mysqldata_3307' returned non-zero exit status 1
/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py:711: CalledProcessError
------------------------- Captured stderr setup ----------------------
[ERROR] Can't locate the language directory.
此外,脚本mysql_install_db
被弃用:http://dev.mysql.com/doc/refman/5.7/en/mysql-install-db.html
如何使用mysql
夹具从pytest dbfixtures ?有没有办法在OS X上使用MySQL 5.7?
你能举一个例子来说明你如何引用'mysql' fixture? –
更新了文章 –
只是为了澄清,同样的例子在Ubuntu上运行在流浪机器上。 –