Xargs:通过"查找"tests.py manage.py 测试



我尝试在django项目目录中执行以下bash命令。我正在使用django-nose作为测试运行器。

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的正确方法是什么?

以下命令是正确的:

find . -name tests.py -print0 | xargs -0 -Ixxx ./manage.py test xxx --settings=project_name.conf.test.settings

在运行它之前,我刚刚做了rm .noseids。如果您使用错误的参数执行./manage.py test,它总是会导致问题。然后用.noseids编写,然后每次执行。

最新更新