Django 1.11:在我的并行测试运行中,什么"pickle"失败了?



我使用的是 dockerized 的 Django 1.11,现在想并行运行我长期存在的测试套件:

manage.py test mainfolder --parallel -v2

尽管它在我的测试套件中失败了 2 分钟(在所有到目前为止运行的测试成功之后(,并出现泡菜错误。但是,堆栈跟踪没有给我指示它发生的位置。我怎样才能更接近失败的东西? 已安装tblib

test_foo (myapp.some.testmodule.SomeTestCase) ... ok
Traceback (most recent call last):
File "./myapp/manage.py", line 34, in <module>
execute_from_command_line()
File "/var/venv-stable/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/var/venv-stable/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/venv-stable/lib/python2.7/site-packages/django/core/management/commands/test.py", line 29, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/var/venv-stable/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/var/venv-stable/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/var/venv-stable/lib/python2.7/site-packages/django/core/management/commands/test.py", line 62, in handle
failures = test_runner.run_tests(test_labels)
File "/var/venv-stable/lib/python2.7/site-packages/django/test/runner.py", line 603, in run_tests
result = self.run_suite(suite)
File "/var/venv-stable/lib/python2.7/site-packages/django/test/runner.py", line 567, in run_suite
return runner.run(suite)
File "/usr/lib/python2.7/unittest/runner.py", line 151, in run
test(result)
File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
return self.run(*args, **kwds)
File "/var/venv-stable/lib/python2.7/site-packages/django/test/runner.py", line 370, in run
subsuite_index, events = test_results.next(timeout=0.1)
File "/usr/lib/python2.7/multiprocessing/pool.py", line 659, in next
raise value
cPickle.PicklingError: Can't pickle <type 'module'>: attribute lookup __builtin__.module failed

在内心深处,我有一个__init__方法混合到一个测试用例中,而不是我写的。它将对导入模块的引用存储到类中,我不知道这对谁有意义。

from django.core import mail
def __init__(self, *args, **kwargs):
super(EmailTestHelperMixin, self).__init__(*args, **kwargs)
self.mail = mail

删除它解决了我的问题。

相关内容

  • 没有找到相关文章

最新更新