Merge lp:~mbp/bzr/fixtures into lp:bzr
| Status: | Merged |
|---|---|
| Merged at revision: | 5317 |
| Proposed branch: | lp:~mbp/bzr/fixtures |
| Merge into: | lp:bzr |
| Diff against target: |
117 lines (+86/-0) 4 files modified
NEWS (+3/-0) bzrlib/tests/__init__.py (+1/-0) bzrlib/tests/fixtures.py (+40/-0) bzrlib/tests/test_fixtures.py (+42/-0) |
| To merge this branch: | bzr merge lp:~mbp/bzr/fixtures |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Robert Collins (community) | 2010-05-14 | Resubmit on 2010-05-23 | |
|
Review via email:
|
|||
Description of the Change
This adds the camel's nose of test fixtures as a separate comment.
The specific case I start with is generating unicode strings for use in tests.
See also http://
- 5232. By Martin Pool on 2010-05-14
-
Change factories from make_ to choose_
| Martin Pool (mbp) wrote : | # |
On 24 May 2010 07:17, Robert Collins <email address hidden> wrote:
> Review: Resubmit
> Firstly, setUp and tearDown are a great way to separate specification ('I want 4 branches, 3 repositories, 2 servers and a merge proposal in my test') and instantiation ('Dude, where are my branches?'). So I think that setUp/tearDown or a similar pairing are really good to have, because if we do want to be able to have reusable fixtures or declarative fixtures, we won't want to have all their overhead at test suite load time. decorators are another way to achieve that, but it ends up just being function currying, and you don't seem to be taking a decorate-and-insert approach here, either.
Are you saying that the contract of the fixture should have a
setUp/tearDown, or that they should be constructed from the setUp of
the TestCase? If the former then I do agree, as we discussed in
person a while ago. It's useful to separate construction of the
object from its actual preparation. The rationale should be
documented though.
>
> Secondly, AIUI you want to head towards a 'what, not how' approach - but this new fixture seems a bit unclear about which it is.
Agree on both points ;-) I think I'm still trying things on.
>
> Oh, and are you aware of self.getUniqueS
No, I wasn't aware of that. Anyhow, it is an interesting case -
ideally we want something that scales from that to something very
expensive.
--
Martin <http://

Firstly, setUp and tearDown are a great way to separate specification ('I want 4 branches, 3 repositories, 2 servers and a merge proposal in my test') and instantiation ('Dude, where are my branches?'). So I think that setUp/tearDown or a similar pairing are really good to have, because if we do want to be able to have reusable fixtures or declarative fixtures, we won't want to have all their overhead at test suite load time. decorators are another way to achieve that, but it ends up just being function currying, and you don't seem to be taking a decorate-and-insert approach here, either.
Secondly, AIUI you want to head towards a 'what, not how' approach - but this new fixture seems a bit unclear about which it is.
Oh, and are you aware of self.getUniqueS tring on TestCase? We'll probably want to migrate such things across eventually - it might be worth peeking at its implementation to see how some existing do-things-uniquely code is hanging together. In particular, and I know its trivial, the manual counting for unique numbers seems like a case where you could experiment with how you want things to compose.
All in all I think this can shape up nicely, but I'd like to see a bit more please. Marking work in progress, as after 9 days unreviewed I don't think someone else is going to pop up Right Now :)
If you'd like to land just this bit I'd be ko with that if you add setup and teardown to the contract, and a reference - base class, or standalone do-nothing - that describes the contract and how you hope people will use it.