clone_test_with_new_id shares details dict between test case instances

Bug #637725 reported by Andrew Bennetts
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
testtools
Fix Released
Low
Andrew Bennetts

Bug Description

clone_test_with_new_id (or bzr's independent implementation, bzrlib.tests.clone_test) essentially just does a copy.copy of the test.

Unfortunately, the copy will share some attributes that should not be shared, especially __details and _cleanups.

In bzrlib's case this makes it difficult to read test failures when parameterised tests are involved — all parameterisations of a test share a details dict, so you might e.g. get 10 failing tests, each showing *10* tracebacks. In bzrlib's case it appears that a trivial __copy__ method that doesn't try to actually copy the instance but instead instantiates a new test case from scratch is an adequate workaround, but I'm not sure this is a good fix in general.

Perhaps clone_test_with_new_id should to be a method on TestCase? Or perhaps testtools.TestCase should provide a __copy__ and/or __deepcopy__ implementation.

Related branches

Revision history for this message
Jonathan Lange (jml) wrote :

It can't merely be a method on TestCase, since we need to clone non-testtools TestCases. I like the other ideas though.

Changed in testtools:
status: New → Triaged
importance: Undecided → Low
Jonathan Lange (jml)
Changed in testtools:
status: Triaged → Fix Committed
assignee: nobody → Andrew Bennetts (spiv)
Jonathan Lange (jml)
Changed in testtools:
milestone: none → 0.9.7
Jonathan Lange (jml)
Changed in testtools:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.