2

在使用pytest-django测试 Django 应用程序时,我遇到了 Travis 的一个奇怪问题。我所有的测试都在本地通过,显然也在 travis 上通过,但无论我做什么,每次都会node-sass出错node-gyp

我的测试都没有使用任何节点模块(如果可能的话)。我确实使用了具有 gulp-sass 的 gulp,但是在测试运行之前运行它似乎工作正常。

这是错误输出:

$ py.test --ds=<project>.settings.travis
============================= test session starts ==============================
platform linux -- Python 3.4.2 -- py-1.4.26 -- pytest-2.6.4
django settings: <project>.settings.travis (from command line option)
plugins: django
collected 13 items / 7 errors 
<project>/tests/test_<suite_1>.py ..........
<project>/tests/test_<suite_2>.py ...
==================================== ERRORS ====================================
 ERROR collecting node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py 
../../../virtualenv/python3.4.2/lib/python3.4/site-packages/_pytest/python.py:463: in _importtestmodule
    mod = self.fspath.pyimport(ensuresyspath=True)
../../../virtualenv/python3.4.2/lib/python3.4/site-packages/py/_path/local.py:629: in pyimport
    __import__(pkgpath.basename)
E     File "/home/travis/build/<user>/<project>/node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 37
E       print '%s:%s:%d:%s %s' % (mode.upper(), os.path.basename(ctx[0]),
E                            ^
E   SyntaxError: invalid syntax
 ERROR collecting node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/gyp/pylib/gyp/common_test.py 
../../../virtualenv/python3.4.2/lib/python3.4/site-packages/_pytest/python.py:463: in _importtestmodule
    mod = self.fspath.pyimport(ensuresyspath=True)
../../../virtualenv/python3.4.2/lib/python3.4/site-packages/py/_path/local.py:629: in pyimport
    __import__(pkgpath.basename)
E     File "/home/travis/build/<user>/<project>/node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 37
E       print '%s:%s:%d:%s %s' % (mode.upper(), os.path.basename(ctx[0]),
E                            ^
E   SyntaxError: invalid syntax
 ERROR collecting node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py 
../../../virtualenv/python3.4.2/lib/python3.4/site-packages/_pytest/python.py:463: in _importtestmodule
    mod = self.fspath.pyimport(ensuresyspath=True)
../../../virtualenv/python3.4.2/lib/python3.4/site-packages/py/_path/local.py:629: in pyimport
    __import__(pkgpath.basename)
E     File "/home/travis/build/<user>/<project>/node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 37
E       print '%s:%s:%d:%s %s' % (mode.upper(), os.path.basename(ctx[0]),
E                            ^
E   SyntaxError: invalid syntax
 ERROR collecting node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/gyp/pylib/gyp/input_test.py 
../../../virtualenv/python3.4.2/lib/python3.4/site-packages/_pytest/python.py:463: in _importtestmodule
    mod = self.fspath.pyimport(ensuresyspath=True)
../../../virtualenv/python3.4.2/lib/python3.4/site-packages/py/_path/local.py:629: in pyimport
    __import__(pkgpath.basename)
E     File "/home/travis/build/<user>/<project>/node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 37
E       print '%s:%s:%d:%s %s' % (mode.upper(), os.path.basename(ctx[0]),
E                            ^
E   SyntaxError: invalid syntax
 ERROR collecting node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py 
../../../virtualenv/python3.4.2/lib/python3.4/site-packages/_pytest/python.py:463: in _importtestmodule
    mod = self.fspath.pyimport(ensuresyspath=True)
../../../virtualenv/python3.4.2/lib/python3.4/site-packages/py/_path/local.py:629: in pyimport
    __import__(pkgpath.basename)
E     File "/home/travis/build/<user>/<project>/node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 37
E       print '%s:%s:%d:%s %s' % (mode.upper(), os.path.basename(ctx[0]),
E                            ^
E   SyntaxError: invalid syntax
 ERROR collecting node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py 
../../../virtualenv/python3.4.2/lib/python3.4/site-packages/_pytest/python.py:463: in _importtestmodule
    mod = self.fspath.pyimport(ensuresyspath=True)
../../../virtualenv/python3.4.2/lib/python3.4/site-packages/py/_path/local.py:629: in pyimport
    __import__(pkgpath.basename)
E     File "/home/travis/build/<user>/<project>/node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 37
E       print '%s:%s:%d:%s %s' % (mode.upper(), os.path.basename(ctx[0]),
E                            ^
E   SyntaxError: invalid syntax
 ERROR collecting node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py 
../../../virtualenv/python3.4.2/lib/python3.4/site-packages/_pytest/python.py:463: in _importtestmodule
    mod = self.fspath.pyimport(ensuresyspath=True)
../../../virtualenv/python3.4.2/lib/python3.4/site-packages/py/_path/local.py:629: in pyimport
    __import__(pkgpath.basename)
E     File "/home/travis/build/<user>/<project>/node_modules/gulp-sass/node_modules/node-sass/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 37
E       print '%s:%s:%d:%s %s' % (mode.upper(), os.path.basename(ctx[0]),
E                            ^
E   SyntaxError: invalid syntax
===================== 13 passed, 7 error in 20.94 seconds ======================
4

1 回答 1

0

问题原来是pytest已经安装在 Travis 中的(旧)版本满足pytest-django. 添加正确的版本pytestrequirements.txt解决问题。

于 2016-01-24T15:34:22.230 回答