Merge lp:~spiv/bzr/traceback-accumulation-2.2 into lp:bzr/2.2
| Status: | Merged |
|---|---|
| Approved by: | Andrew Bennetts on 2010-09-16 |
| Approved revision: | 5090 |
| Merged at revision: | 5090 |
| Proposed branch: | lp:~spiv/bzr/traceback-accumulation-2.2 |
| Merge into: | lp:bzr/2.2 |
| Diff against target: |
126 lines (+64/-6) 3 files modified
NEWS (+3/-3) bzrlib/tests/__init__.py (+26/-2) bzrlib/tests/test_selftest.py (+35/-1) |
| To merge this branch: | bzr merge lp:~spiv/bzr/traceback-accumulation-2.2 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| bzr-core | 2010-09-15 | Pending | |
|
Review via email:
|
|||
Commit Message
More robust fix for TestCase cloning, this time with tests.
Description of the Change
Robert pointed out that my simple TestCase.__copy__ would break tests that were created by repeated application of apply_scenarios. I don't think there are any cases of this in bzr's own test suite (we use multiply_scenarios instead, so there's still just one application of a scenario list to a series of tests), but it could break plugins and invites trouble.
So this patch implements __copy__ as:
* shallow copy the instance __dict__
* deep copy individual attributes on a hard-coded blacklist
* create a new instance (skipping __init__) and give it the new __dict__
In addition, this adds two new tests to test_selftest to catch both the original problem and Robert's concern. I feel compelled to point out that if such tests had existed in the first place we wouldn't have this problem now ;)
Finally, this tweaks the relevant NEWS entry.
| Robert Collins (lifeless) wrote : | # |
| Andrew Bennetts (spiv) wrote : | # |
As the comment in the patch says this is something I think testtools ought to provide, but it seems to me that as a practical matter it's easiest to include a fix in bzrlib that works even with older, unfixed testtools. We often take the same approach with other dependencies, like Python itself. I realise that testtools takes patches and releases new versions more frequently and readily than Python, but it's considerably more effort to get all of PQM, babune, and developers' systems updated with a new testtools than it is to just put a fix in bzr now, and allow those to be updated at leisure.
| Martin Pool (mbp) wrote : | # |
I think it's ok to have a workaround of this size in bzr, as long as
there's an explanation why.
I think needing to override __copy__ is kind of a bad smell in Python.
- 5089. By Andrew Bennetts on 2010-09-15
-
Restore accidentally deleted test docstring.
- 5090. By Andrew Bennetts on 2010-09-15
-
Add detailed comment explaining the __copy__ method.
| Andrew Bennetts (spiv) wrote : | # |
I've added a comment to __copy__ to explain why it's there (and how it works).
| Andrew Bennetts (spiv) wrote : | # |
sent to pqm by email

I think this is really rather in the wrong place - testtools is the source of the bug.