dja*_*aut 5 python django unit-testing multiprocessing
我使用的是 dockerized Django 1.11,现在想并行运行我长期存在的测试套件:
manage.py test mainfolder --parallel -v2
尽管它在我的测试套件中 2 分钟后失败(到目前为止所有运行测试都成功),并出现 pickle 错误。然而,堆栈跟踪并没有告诉我它发生在哪里。我怎样才能更接近失败的地方呢?
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
Run Code Online (Sandbox Code Playgroud)
在内心深处,我有一个__init__方法混合到测试用例中,而不是我编写的。它将对导入模块的引用存储到类中,我不知道这对谁有意义。
from django.core import mail
def __init__(self, *args, **kwargs):
super(EmailTestHelperMixin, self).__init__(*args, **kwargs)
self.mail = mail
Run Code Online (Sandbox Code Playgroud)
删除它解决了我的问题。
| 归档时间: |
|
| 查看次数: |
1786 次 |
| 最近记录: |