(第28回)Python mini Hack-a-thon / sqlalchemy のテストを動かす [Python]
【ソースを取得する】
1. 本家のリポジトリの他に bitbucket.org に公式ミラーがあるので、それを fork する
https://bitbucket.org/sqlalchemy/sqlalchemy
2. hg clone ssh://hg@bitbucket.org/nakagami/sqlalchemy
【Python2 でのテスト】
1. README.unittest.rst を見る
2. nose のインストール https://nose.readthedocs.org/
3. python2.7 sqla_nose.py (sqlite3 でテスト)
4. test.cfg に、下のような感じで mysql の設定をする
5. python2.7 sqla_nose.py --verbose --db=mysql (mysql でテスト)
【Python3 でのテスト】
1. README.py3k を見る
2. nose のインストール
3. python3.3 sa2to3.py --no-diffs -w lib test examples (ソースの変換)
4. python3.3 sqla_nose.py (sqlite3 でテスト)
5. test.cfg の設定(上参照)
6. python3.3 sqla_nose.py --verbose --db=mysql (動かない)
------------------------------------【終了】--------------------------------------------
------------------------------------【再開】--------------------------------------------
【cymysql を使ってみる】
http://pypi.python.org/pypi/cymysql
[1. python2.7 sqla_nose.py --verbose --db=mysql]
[2. python3.3 sqla_nose.py --verbose --db=mysql]
(ステップ1)python3.3 で動かない→ cymysql のソース修正
https://github.com/nakagami/CyMySQL/commit/330818e0aff5d11f0a42e31f05c2e826a4737edb
(ステップ2)python3.3 のテスト実行中で止まる
test.engine.test_transaction.TransactionTest でブロック。テスト削除して実行
・・・・ここまでで sqlalchemy は、まだ使っていない
1. 本家のリポジトリの他に bitbucket.org に公式ミラーがあるので、それを fork する
https://bitbucket.org/sqlalchemy/sqlalchemy
2. hg clone ssh://hg@bitbucket.org/nakagami/sqlalchemy
【Python2 でのテスト】
1. README.unittest.rst を見る
2. nose のインストール https://nose.readthedocs.org/
3. python2.7 sqla_nose.py (sqlite3 でテスト)
4. test.cfg に、下のような感じで mysql の設定をする
[db] mysql=mysql://scott:tiger@localhost/dbname
5. python2.7 sqla_nose.py --verbose --db=mysql (mysql でテスト)
【Python3 でのテスト】
1. README.py3k を見る
2. nose のインストール
3. python3.3 sa2to3.py --no-diffs -w lib test examples (ソースの変換)
4. python3.3 sqla_nose.py (sqlite3 でテスト)
5. test.cfg の設定(上参照)
6. python3.3 sqla_nose.py --verbose --db=mysql (動かない)
------------------------------------【終了】--------------------------------------------
------------------------------------【再開】--------------------------------------------
【cymysql を使ってみる】
http://pypi.python.org/pypi/cymysql
diff -r 7f3494ebad58 lib/sqlalchemy/connectors/mysqldb.py --- a/lib/sqlalchemy/connectors/mysqldb.py Thu Feb 14 15:58:11 2013 -0500 +++ b/lib/sqlalchemy/connectors/mysqldb.py Sat Feb 16 14:30:06 2013 +0900 @@ -54,7 +54,7 @@ @classmethod def dbapi(cls): # is overridden when pymysql is used - return __import__('MySQLdb') + return __import__('cymysql') def do_executemany(self, cursor, statement, parameters, context=None): rowcount = cursor.executemany(statement, parameters)
[1. python2.7 sqla_nose.py --verbose --db=mysql]
Ran 4838 tests in 412.587s FAILED (SKIP=109, errors=12, failures=4)
[2. python3.3 sqla_nose.py --verbose --db=mysql]
(ステップ1)python3.3 で動かない→ cymysql のソース修正
https://github.com/nakagami/CyMySQL/commit/330818e0aff5d11f0a42e31f05c2e826a4737edb
(ステップ2)python3.3 のテスト実行中で止まる
test.engine.test_transaction.TransactionTest でブロック。テスト削除して実行
Ran 2049 tests in 172.751s FAILED (SKIP=101, errors=813, failures=4)
・・・・ここまでで sqlalchemy は、まだ使っていない
コメント 0