Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django测试:TypeError:应为unicode参数,获得';str';_Python_Django_Unicode - Fatal编程技术网

Python Django测试:TypeError:应为unicode参数,获得';str';

Python Django测试:TypeError:应为unicode参数,获得';str';,python,django,unicode,Python,Django,Unicode,编辑:我找到了一份工作。通过添加smart_unicode(来自django.utils.encoding导入smart_unicode)并在引发错误的字符串之前放置“u”,并在设置部分添加默认的_CHARSET='utf-8',测试将运行 他们失败了。但是他们跑了。问题结束。 ~~~~~~~~~~~~~~~~~~~~~~~~~ 使用Django 1.6.7 你好 正在尝试从此github(一个允许在Django Oscar中进行条带支付的项目)运行此Django代码的测试: 我得到一个错误:

编辑:我找到了一份工作。通过添加smart_unicode(来自django.utils.encoding导入smart_unicode)并在引发错误的字符串之前放置“u”,并在设置部分添加默认的_CHARSET='utf-8',测试将运行

他们失败了。但是他们跑了。问题结束。 ~~~~~~~~~~~~~~~~~~~~~~~~~

使用Django 1.6.7

你好

正在尝试从此github(一个允许在Django Oscar中进行条带支付的项目)运行此Django代码的测试:

我得到一个错误:

/stripetest/django-oscar-stripe$ ./runtests.py
nosetests --verbosity 1 t e s t _ a r g s -s --with-spec
Creating test database for alias 'default'...

Unloadable or unexecutable test.

A Failure case is placed in a test suite to indicate the presence of a
test that could not be loaded or executed. A common example is a test
module that fails to import.
- runTest (ERROR)
- runTest (ERROR)
- runTest (ERROR)
- runTest (ERROR)
- runTest (ERROR)
- runTest (ERROR)
- runTest (ERROR)
- runTest (ERROR)
- runTest (ERROR)
Traceback (most recent call last):
  File "./runtests.py", line 60, in <module>
    run_tests('*args')
  File "./runtests.py", line 48, in run_tests
    num_failures = test_runner.run_tests('test_args')
  File "/home/david/.virtualenvs/stripetest/local/lib/python2.7/site-packages/django_nose/runner.py", line 155, in run_tests
result = self.run_suite(nose_argv)
File "/home/david/.virtualenvs/stripetest/local/lib/python2.7/site-packages/django_nose/runner.py", line 117, in run_suite
    addplugins=plugins_to_add)
  File "/home/david/.virtualenvs/stripetest/local/lib/python2.7/site-packages/nose/core.py", line 121, in __init__
    **extra_args)
  File "/usr/lib/python2.7/unittest/main.py", line 95, in __init__
    self.runTests()
  File "/home/david/.virtualenvs/stripetest/local/lib/python2.7/site-packages/nose/core.py",     line 207, in runTests
    result = self.testRunner.run(self.test)
  File "/home/david/.virtualenvs/stripetest/local/lib/python2.7/site-packages/nose/core.py", line 66, in run
    result.printErrors()
  File "/home/david/.virtualenvs/stripetest/local/lib/python2.7/site-packages/nose/result.py", line 103, in printErrors
    _TextTestResult.printErrors(self)
  File "/usr/lib/python2.7/unittest/runner.py", line 107, in printErrors
    self.stream.writeln()
  File "/usr/lib/python2.7/unittest/runner.py", line 25, in writeln
    self.write('\n') # text-mode streams translate to \r\n if needed
TypeError: unicode argument expected, got 'str'
/stripetest/django oscar stripe$。/runtests.py
鼻测试——详细1 t e s t a r g s-s——带有规范
正在为别名“default”创建测试数据库。。。
不可加载或不可执行的测试。
故障案例放在测试套件中,以指示存在故障
无法加载或执行的测试。一个常见的例子是测试
无法导入的模块。
-运行测试(错误)
-运行测试(错误)
-运行测试(错误)
-运行测试(错误)
-运行测试(错误)
-运行测试(错误)
-运行测试(错误)
-运行测试(错误)
-运行测试(错误)
回溯(最近一次呼叫最后一次):
文件“/runtests.py”,第60行,在
运行_测试(“*args”)
运行测试中第48行的文件“/runtests.py”
num_failures=测试运行程序。运行测试('test_args'))
文件“/home/david/.virtualenvs/stripetest/local/lib/python2.7/site packages/django\u nose/runner.py”,第155行,运行测试中
结果=自运行套件(nose\u argv)
文件“/home/david/.virtualenvs/stripetest/local/lib/python2.7/site packages/django\u nose/runner.py”,第117行,在run\u套件中
addplugins=插件\u到\u添加)
文件“/home/david/.virtualenvs/stripetest/local/lib/python2.7/site packages/nose/core.py”,第121行,在__
**额外参数)
文件“/usr/lib/python2.7/unittest/main.py”,第95行,在__
self.runTests()
runTests中的第207行文件“/home/david/.virtualenvs/stripetest/local/lib/python2.7/site packages/nose/core.py”
结果=self.testRunner.run(self.test)
文件“/home/david/.virtualenvs/stripetest/local/lib/python2.7/site packages/nose/core.py”,第66行,正在运行
result.printErrors()
printErrors中的文件“/home/david/.virtualenvs/stripetest/local/lib/python2.7/site packages/nose/result.py”,第103行
_TextTestResult.printErrors(自身)
文件“/usr/lib/python2.7/unittest/runner.py”,第107行,在printErrors中
self.stream.writeln()
文件“/usr/lib/python2.7/unittest/runner.py”,第25行,以书面形式
如果需要,self.write('\n')#文本模式流将转换为\r\n
TypeError:应为unicode参数,得到'str'
我已经为此奋斗了几个小时,却一事无成。我尝试过将相关行过滤为unicode(从('test_args')到('test_args'))。同样的错误。按foo.encode('utf-8')进行过滤。同样的错误

非常感谢您的帮助。因为这不是我的代码,而且我从未使用过Nose、coverage或OptPass,所以我在挣扎

谢谢

/stripetest/django-oscar-stripe$ ./runtests.py
nosetests --verbosity 1 t e s t _ a r g s -s --with-spec
Creating test database for alias 'default'...

Unloadable or unexecutable test.

A Failure case is placed in a test suite to indicate the presence of a
test that could not be loaded or executed. A common example is a test
module that fails to import.
- runTest (ERROR)
- runTest (ERROR)
- runTest (ERROR)
- runTest (ERROR)
- runTest (ERROR)
- runTest (ERROR)
- runTest (ERROR)
- runTest (ERROR)
- runTest (ERROR)
Traceback (most recent call last):
  File "./runtests.py", line 60, in <module>
    run_tests('*args')
  File "./runtests.py", line 48, in run_tests
    num_failures = test_runner.run_tests('test_args')
  File "/home/david/.virtualenvs/stripetest/local/lib/python2.7/site-packages/django_nose/runner.py", line 155, in run_tests
result = self.run_suite(nose_argv)
File "/home/david/.virtualenvs/stripetest/local/lib/python2.7/site-packages/django_nose/runner.py", line 117, in run_suite
    addplugins=plugins_to_add)
  File "/home/david/.virtualenvs/stripetest/local/lib/python2.7/site-packages/nose/core.py", line 121, in __init__
    **extra_args)
  File "/usr/lib/python2.7/unittest/main.py", line 95, in __init__
    self.runTests()
  File "/home/david/.virtualenvs/stripetest/local/lib/python2.7/site-packages/nose/core.py",     line 207, in runTests
    result = self.testRunner.run(self.test)
  File "/home/david/.virtualenvs/stripetest/local/lib/python2.7/site-packages/nose/core.py", line 66, in run
    result.printErrors()
  File "/home/david/.virtualenvs/stripetest/local/lib/python2.7/site-packages/nose/result.py", line 103, in printErrors
    _TextTestResult.printErrors(self)
  File "/usr/lib/python2.7/unittest/runner.py", line 107, in printErrors
    self.stream.writeln()
  File "/usr/lib/python2.7/unittest/runner.py", line 25, in writeln
    self.write('\n') # text-mode streams translate to \r\n if needed
TypeError: unicode argument expected, got 'str'