64

私たちのPythonプロジェクトには、いくつかの依存モジュールをリストしたrequirements.txtファイルがあります。以前は使用していました

pip install -r requirements.txt

これらの依存関係をインストールします。現在、toxを使用してテスト環境を構築しています。私の質問は、requirements.txtを介してモジュールを直接インストールする方法です。

以下は、tox.iniとrequirements.txtです。

tox.ini:

[tox]
envlist=py27
[testenv]
deps=pytest
     boto
commands=py.test

rquirements.txt:

boto

tox.iniから「boto」を削除して次のようなものを追加する方法はありますか

deps_files=requirements.txt
4

4 に答える 4

68
 deps = -r{toxinidir}/tools/pip-requires
        -r{toxinidir}/tools/test-requires
于 2012-09-04T07:16:23.780 に答える
33

What helped me is the following (the other solution didn't work for me):

deps=
    pytest
    -rrequirements.txt

This works at least if you add requirements.txt to MANIFEST.in and if you use a relatively new `tox (>= 1.6.1) version (see here).

于 2013-09-23T16:56:03.897 に答える
24

I had already setup my dependencies as in the accepted answer above, however any new dependencies were not installed like they are when tox is run for the first time. To install new dependencies in the virtualenv I had to force tox to recreate the environment like so:

tox --recreate -e py27

[UPDATE: this issue should be fixed in tox v4]

于 2016-05-26T01:43:39.257 に答える
10

You can put dependencies and test dependencies in requirements.txt and requirements.testing.txt in order to the root directory.

Put tox.ini in your root directory of your project and you can use the approach below to install dependencies.

[testenv] deps = -r{toxinidir}/requirements.txt -r{toxinidir}/requirements.testing.txt

In addition to upgrade dependencies

[testenv] deps = -Ur{toxinidir}/requirements.txt -Ur{toxinidir}/requirements.testing.txt

于 2017-12-03T12:20:51.800 に答える