← Back to team overview

testtools-dev team mailing list archive

[Bug 637725] [NEW] clone_test_with_new_id shares details dict between test case instances

 

Public bug reported:

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.

** Affects: testtools
     Importance: Undecided
         Status: New

-- 
clone_test_with_new_id shares details dict between test case instances
https://bugs.launchpad.net/bugs/637725
You received this bug notification because you are a member of testtools
developers, which is subscribed to testtools.

Status in testtools: New

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.





Follow ups

References