我試圖從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上運行在流浪機器上。 –