0

我尝试在 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

完整回溯(没有命令-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在这种情况下使用的正确方法是什么?

4

1 回答 1

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每次都写入并执行。

于 2012-09-24T06:50:47.677 回答