You can debug by adding code like this to django/test/runner.py just after 
it determined the args (around line 315 in django 1.9):

import pickle
for arg in args:
    print(arg)
    pickle.dumps(arg)

I found that pickle raises the same exceptions as cPickle, but, since it's 
all Python, lets you set breakpoints around the exception to find out 
what's going on.

The ModuleImportFailure for example comes from python's system-wide 
unittest/loader.py from a function called _make_failed_import_test where 
it's dynamically created and hence can't be pickled. Setting a breakpoint 
inside that method around the error message should give you the required 
pointers to fix the import and thus the pickle exception.

For anyone else coming here and debugging pickle exceptions: another 
failure I ran into was from calling unittest.TestCase.addCleanup() with an 
instancemethod, e.g. something like self.addCleanup(self.remove_things). 
Making self.remove_things a global function fixed this too.

Hope this helps!


On Monday, February 29, 2016 at 12:13:08 PM UTC-5, girish ramnani wrote:
>
> when running the django test in parallel using the runner.py . 
> _pickle.PicklingError: Can't pickle <class 
> 'unittest.loader.ModuleImportFailure'>: attribute lookup 
> ModuleImportFailure on unittest.loader failed
>
> error is thrown, and when the runner is run using a single process. the 
> test suite executes.
>
> I am using a new virtualenv with django installed in editable mode.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3989ea02-ce27-4283-b24f-b121d364afea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to