Code review comment for lp:~bjornt/launchpad/more-unique-factory-strings

Revision history for this message
Björn Tillenius (bjornt) wrote :

On Mon, May 17, 2010 at 02:28:30PM -0000, Jonathan Lange wrote:
> 2010/5/17 Björn Tillenius <email address hidden>:
> > If we see a test failing due to this, we can
> > quite easily make sure that it's really unique within an instance, by
> > keeping track of generated uuids.
> >
>
> Or you could drop the uuid approach and simply put id(self) into the
> string before the getUniqueInteger()-generated segment.

I'd rather stick with uuid, since id() seems to be to prone to generated
duplicates:

    >>> def foo():
    ... foo_factory = LaunchpadObjectFactory()
    ... print id(foo_factory)
    ...
    >>> foo()
    124609680
    >>> foo()
    124609680

If I would have used id(self) and used the factory to create objects in
foo(), it would have failed the second time.

--
Björn Tillenius | https://launchpad.net/~bjornt

« Back to merge proposal