I would like to use tox
to run my unittests in two virtualenvs, since my application has to support 2 different Python versions.
我希望使用tox来在两个virtualenv中运行我的unittest,因为我的应用程序必须支持两个不同的Python版本。
My problem is that tox
requires a setup.py
, but I have none since my application is not a module and has its own installer. For now I don't want to go through the hassle of automating the install process as to work with setup.py
, I just want to run my unittests without having to write a setup.py
.
我的问题是,托克斯需要一个设置。py,但我没有,因为我的应用程序不是一个模块,并且有它自己的安装程序。现在,我不希望在使用安装时经历自动安装过程的麻烦。py,我只想运行unittests而不需要写setup.py。
Is that possible? Or how can I write an "empty" setup.py that simply does nothing? Can you point me towards some documentation on the subject (the distutils
documentation explains how to write a meaningful setup.py
, not an empty one)?
这有可能吗?或者我如何写一个“空”的设置。什么都不做?您能给我指出一些关于这个主题的文档吗? (distutils文档解释了如何编写有意义的设置。py,不是空的)?
3 个解决方案
#1
71
After digging inside the source code, I found a scarcely documented option in tox.ini that skips sdist:
在深入源代码之后,我在tox找到了一个几乎没有文档记录的选项。ini跳过sdist:
[tox]
skipsdist = BOOL # defaults to false
Setting this to True
I got what I wanted, saving me the effort of writing a meaningful setup.py
把这个设定成现实,我得到了我想要的,省去了我写一个有意义的setup.py的努力
#2
36
If you have an application (with a requirements.txt
), rather than a project that you are going to distribute (which would have a setup.py
instead), your tox.ini
should look something like this:
如果您有一个应用程序(带有requirements.txt),而不是要分发的项目(它将有一个设置)。py),而不是你的毒药。ini应该是这样的:
[tox]
skipsdist = True
[testenv]
deps = -r{toxinidir}/requirements.txt
Found this answer originally from David Murphy's blog: http://blog.schwuk.com/2014/03/19/using-tox-django-projects/
这个答案来自David Murphy的博客:http://blog.schwuk.com/2014/03/19/using-tox-django-projects/
#3
0
This is my tox.ini file content for Django project by multiple settings:
这是我的毒药。多个设置为Django项目的ini文件内容:
[tox]
envlist = py36-{accounting,content,media}_settings
skipsdist = true
[testenv]
commands = python {toxinidir}/manage.py test
deps = -r{toxinidir}/requirements.txt
setenv =
accounting_settings: DJANGO_SETTINGS_MODULE=my_project.settings.accounting
contents_settings: DJANGO_SETTINGS_MODULE=my_project.settings.contents
media_settings: DJANGO_SETTINGS_MODULE=my_project.settings.media
#1
71
After digging inside the source code, I found a scarcely documented option in tox.ini that skips sdist:
在深入源代码之后,我在tox找到了一个几乎没有文档记录的选项。ini跳过sdist:
[tox]
skipsdist = BOOL # defaults to false
Setting this to True
I got what I wanted, saving me the effort of writing a meaningful setup.py
把这个设定成现实,我得到了我想要的,省去了我写一个有意义的setup.py的努力
#2
36
If you have an application (with a requirements.txt
), rather than a project that you are going to distribute (which would have a setup.py
instead), your tox.ini
should look something like this:
如果您有一个应用程序(带有requirements.txt),而不是要分发的项目(它将有一个设置)。py),而不是你的毒药。ini应该是这样的:
[tox]
skipsdist = True
[testenv]
deps = -r{toxinidir}/requirements.txt
Found this answer originally from David Murphy's blog: http://blog.schwuk.com/2014/03/19/using-tox-django-projects/
这个答案来自David Murphy的博客:http://blog.schwuk.com/2014/03/19/using-tox-django-projects/
#3
0
This is my tox.ini file content for Django project by multiple settings:
这是我的毒药。多个设置为Django项目的ini文件内容:
[tox]
envlist = py36-{accounting,content,media}_settings
skipsdist = true
[testenv]
commands = python {toxinidir}/manage.py test
deps = -r{toxinidir}/requirements.txt
setenv =
accounting_settings: DJANGO_SETTINGS_MODULE=my_project.settings.accounting
contents_settings: DJANGO_SETTINGS_MODULE=my_project.settings.contents
media_settings: DJANGO_SETTINGS_MODULE=my_project.settings.media