← Back to team overview

dulwich-users team mailing list archive

Re: [PATCH 01/10] Allow overwriting id property of objects in test utils.

 

On Sun, Aug 8, 2010 at 11:48, Jelmer Vernooij <jelmer@xxxxxxxxx> wrote:

> Hi Dave,
>
> On Mon, 2010-08-02 at 12:46 -0700, dborowitz@xxxxxxxxxx wrote:
> > From: Dave Borowitz <dborowitz@xxxxxxxxxx>
> >
> > Change-Id: I1f2da810b6466575bf82c0cbadaf3f844a0244cc
> > ---
> >  NEWS                          |    2 ++
> >  dulwich/tests/test_objects.py |    7 +++++++
> >  dulwich/tests/utils.py        |   12 ++++++++++--
> >  3 files changed, 19 insertions(+), 2 deletions(-)
> >
> > diff --git a/NEWS b/NEWS
> > index 603d8da..14e067c 100644
> > --- a/NEWS
> > +++ b/NEWS
> > @@ -27,6 +27,8 @@
> >    * New tests in test_web with better coverage and fewer ad-hoc mocks.
> >      (Dave Borowitz)
> >
> > +  * Allow overwriting id property of objects in test utils. (Dave
> Borowitz)
> Can you perhaps expand a bit as to where this would be useful?
>

Well, make_object was already capable of creating objects with arbitrary
members set to arbitrary values. When I cleaning up some of test_server, I
had a bunch of test objects that had their ids set to known values ('1' *
40, etc.), so the easiest way to convert the stub objects in those tests was
to allow overwriting the id property. (Now that I've thought about it, there
are some other alternatives I could use that would be a little more work,
but don't involve this hack to overwrite id.)

See e.g.
http://github.com/dborowitz/dulwich/blob/d0ad3a19cc45701c017e6462f3b52af670116e60/dulwich/tests/test_server.py#L197
(from
patch 3/10) for some usages.


> Cheers,
>
> Jelmer
>

Follow ups

References