[英]xargs: passing 'find' tests.py to manage.py test
我尝试在Django项目目录中执行以下bash命令。 我正在使用django-nose
作为TestRunner。
find . -name \tests.py -print0 | xargs -0 -Ixxx ./manage.py test xxx --settings=project_name.conf.test.settings
但出现以下错误(取决于tests.py文件的数量):
OSError: No such file /Users/user/Projects/project_name/{}
相同的-print0
在第一次tests.py
停止
完全回溯(命令whithout -print0
:
nosetests --verbosity 1 ./project_name/backend/tests.py
./project_name/contrib/auth/tests.py
./project_name/frontend/tests.py
--failed --stop --nocapture --debug=DEBUG --nologcapture
To reuse old database "test_db" for speed, set env var REUSE_DB=1.
To reuse old database "test_db1" for speed, set env var REUSE_DB=1.
Creating test database for alias 'default'...
Creating schema msg
Creating schema dict
Creating test database for alias 'db2'...
Creating schema msg
Creating schema dict
E
======================================================================
ERROR: Failure: OSError (No such file /Users/user/Projects/project_name/{})
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/user/.virtualenvs/project_name/lib/python2.7/site-packages/nose/failure.py", line 39, in runTest
raise self.exc_class(self.exc_val)
OSError: No such file /Users/user/Projects/project_name/{}
----------------------------------------------------------------------
Ran 1 test in 0.001s
FAILED (errors=1)
Destroying test database for alias 'default'...
Destroying test database for alias 'db2'...
在这种情况下使用xargs
的正确方法是什么?
以下命令是正确的:
find . -name \tests.py -print0 | xargs -0 -Ixxx ./manage.py test xxx --settings=project_name.conf.test.settings
在运行它之前,我刚刚做了rm .noseids
。 如果使用错误的参数执行./manage.py test
,总是会引起问题。 然后将其写入.noseids
并在之后每次执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.