我尝试在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
的正确方法是什么?
答案 0 :(得分:0)
以下命令是正确的:
find . -name \tests.py -print0 | xargs -0 -Ixxx ./manage.py test xxx --settings=project_name.conf.test.settings
我在运行之前刚刚做过rm .noseids
。如果用错误的参数执行./manage.py test
,它总是会导致问题。然后它写在.noseids
中并且每次都执行。