Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django test runner fails trying to report errors from parallel tests #336

Closed
apotterri opened this issue Jun 1, 2024 · 1 comment
Closed
Assignees
Labels
bug Something isn't working

Comments

@apotterri
Copy link
Collaborator

When running Django tests in parallel, e.g. runtests.py --parallel 4, a failure in one of the tests raises an exeption:

  File "/Users/ajp/src/django/worktrees/django-5.0/.tox/py312/lib/python3.12/site-packages/_appmap/unittest.py", line 72, in callTestMethod
    wrapped(*args, **kwargs)
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/.asdf/installs/python/3.12.2/lib/python3.12/unittest/case.py", line 589, in _callTestMethod
    if method() is not None:
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/src/django/worktrees/django-5.0/tests/admin_views/tests.py", line 4663, in test_search_with_spaces
    with self.subTest(search=search):
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/.asdf/installs/python/3.12.2/lib/python3.12/contextlib.py", line 158, in __exit__
    self.gen.throw(value)
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/.asdf/installs/python/3.12.2/lib/python3.12/unittest/case.py", line 538, in subTest
    with self._outcome.testPartExecutor(self._subtest, subTest=True):
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/.asdf/installs/python/3.12.2/lib/python3.12/contextlib.py", line 158, in __exit__
    self.gen.throw(value)
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/.asdf/installs/python/3.12.2/lib/python3.12/unittest/case.py", line 73, in testPartExecutor
    self.result.addSubTest(test_case.test_case, test_case, exc_info)
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/src/django/worktrees/django-5.0/django/test/runner.py", line 305, in addSubTest
    self.check_subtest_picklable(test, subtest)
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/src/django/worktrees/django-5.0/django/test/runner.py", line 267, in check_subtest_picklable
    self._confirm_picklable(subtest)
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/src/django/worktrees/django-5.0/django/test/runner.py", line 184, in _confirm_picklable
    pickle.loads(pickle.dumps(obj))
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/src/django/worktrees/django-5.0/.tox/py312/lib/python3.12/site-packages/_appmap/wrapt/wrappers.py", line 462, in __reduce_ex__
    raise NotImplementedError(
    ^^^^^^^^^^^^^^^^^
NotImplementedError: object proxy must define __reduce_ex__()

Attempting to resolve this by moving the implementation of __reduce_ex__ up from wrapt.wrappers.FunctionWrapper to wrapt.wrappers.ObjectProxy (where it seems like it belongs) didn't really help:

  File "/Users/ajp/src/applandinc/appmap-python/_appmap/unittest.py", line 72, in callTestMethod
    wrapped(*args, **kwargs)
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/.asdf/installs/python/3.12.2/lib/python3.12/unittest/case.py", line 589, in _callTestMethod
    if method() is not None:
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/src/django/worktrees/django-5.0/tests/admin_views/tests.py", line 4663, in test_search_with_spaces
    with self.subTest(search=search):
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/.asdf/installs/python/3.12.2/lib/python3.12/contextlib.py", line 158, in __exit__
    self.gen.throw(value)
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/.asdf/installs/python/3.12.2/lib/python3.12/unittest/case.py", line 538, in subTest
    with self._outcome.testPartExecutor(self._subtest, subTest=True):
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/.asdf/installs/python/3.12.2/lib/python3.12/contextlib.py", line 158, in __exit__
    self.gen.throw(value)
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/.asdf/installs/python/3.12.2/lib/python3.12/unittest/case.py", line 73, in testPartExecutor
    self.result.addSubTest(test_case.test_case, test_case, exc_info)
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/src/django/worktrees/django-5.0/django/test/runner.py", line 305, in addSubTest
    self.check_subtest_picklable(test, subtest)
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/src/django/worktrees/django-5.0/django/test/runner.py", line 267, in check_subtest_picklable
    self._confirm_picklable(subtest)
    ^^^^^^^^^^^^^^^^^
  File "/Users/ajp/src/django/worktrees/django-5.0/django/test/runner.py", line 184, in _confirm_picklable
    pickle.loads(pickle.dumps(obj))
    ^^^^^^^^^^^^^^^^^
_pickle.PicklingError: Can't pickle <BoundFunctionWrapper at 0x11850a3c0 for method at 0x116c7a400>: it's not the same object as django.middleware.csrf.CsrfViewMiddleware.process_view
@apotterri
Copy link
Collaborator Author

Fixed by #367

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant