{{{
try:
CharField.register_lookup(Length)
# some test code
finally:
CharField._unregister_lookup(Length)
}}}
It'd be better to use `unittest.addCleanup` to handle this stuff.
--
Ticket URL: <https://code.djangoproject.com/ticket/29658>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/29658#comment:1>
* status: new => assigned
* owner: nobody => Dominic White
--
Ticket URL: <https://code.djangoproject.com/ticket/29658#comment:2>
Comment (by Srinivas Reddy Thatiparthy):
https://code.djangoproject.com/ticket/29658
--
Ticket URL: <https://code.djangoproject.com/ticket/29658#comment:3>
* owner: Dominic White => Srinivas Reddy Thatiparthy
--
Ticket URL: <https://code.djangoproject.com/ticket/29658#comment:4>
* has_patch: 0 => 1
Comment:
The current patch is using a context manager instead of the `try/finally`
method.
Mads, is that something you are comfortable with, or do you still see some
benefit with `addCleanup`?
--
Ticket URL: <https://code.djangoproject.com/ticket/29658#comment:5>
* stage: Accepted => Ready for checkin
Comment:
Patch looks good to me, unless there's some reason to prefer
`addCleanup()`.
--
Ticket URL: <https://code.djangoproject.com/ticket/29658#comment:6>
Comment (by Simon Charette):
Using context managers should be fine as well.
--
Ticket URL: <https://code.djangoproject.com/ticket/29658#comment:7>
Old description:
> There are some places in the test suite that follow this pattern:
>
> {{{
> try:
> CharField.register_lookup(Length)
> # some test code
> finally:
> CharField._unregister_lookup(Length)
> }}}
>
> It'd be better to use `unittest.addCleanup` to handle this stuff.
New description:
There are some places in the test suite that follow this pattern:
{{{
try:
CharField.register_lookup(Length)
# some test code
finally:
CharField._unregister_lookup(Length)
}}}
It'd be better to use a context manager (`addCleanup()` was originally
proposed) to handle this stuff.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/29658#comment:8>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"233c70f0479beb3bff9027e6cff680882978fd4d" 233c70f0]:
{{{
#!CommitTicketReference repository=""
revision="233c70f0479beb3bff9027e6cff680882978fd4d"
Fixed #29658 -- Registered model lookups in tests with a context manager.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29658#comment:9>