[TIP] What are you all using for fixtures?

Randy Syring randy at thesyrings.us
Thu Jul 3 19:35:33 PDT 2014


We have a policy of always having a .testing_create() classmethod on 
each entity object which is responsible for creating the object with 
whatever data is needed to satisfy database constraints.  That would 
include and dependent objects, as needed.

So, if I need an Order entity for testing, in the test, I'm only 
responsible for:

# delete all orders and anything dependent on orders, this method is 
responsible for knowing what depends on orders and calling 
dependent_object.delete_all_cascaded() for those tables.  But only one 
level deep since the dependent objects are also responsible for taking 
care of dependencies.

Orders.delete_all_cascaded()

I always delete all objects when beginning a test to avoid cross-test 
contamination.

# create order with sane defaults, pass in parameters to change values 
that need to be updated for testing.
Orders.testing_create(...)

FWIW.  :)

*Randy Syring*
Husband | Father | Redeemed Sinner

/"For what does it profit a man to gain the whole world
and forfeit his soul?" (Mark 8:36 ESV)/

On 07/03/2014 07:48 AM, Marcin Tustin wrote:
>
> Hi All,
>
> Right now I’m looking for alternatives to the farmdev fixture module 
> (http://farmdev.com/projects/fixture/) for loading fixture data with 
> sqlalchemy. My main problem with that library is that while it’s easy 
> to use (nice, human-editable way of specifying fixtures), the teardown 
> code in particular is rather buggy (among other issues, it will issue 
> deletes twice for each row, the second time with some data as strings 
> where they were ints before).
>
> What are you using, and why do you like or dislike it?
>
> Marcin
>
> *Marcin Tustin*
> Senior Software Engineer
>
> ------------------------------------------------------------------------
>
>
> 1111 Marcus Avenue
> Lake Success, NY 11042
> dealertrack.com <https://www.dealertrack.com/>
>
> p 516.300.7072
>
>
> *dealertrack **technologies*™
>
> Confidentiality Notice: This e-mail and any attachments may contain 
> confidential, proprietary information of Dealertrack Technologies. It 
> is intended solely for the named recipient(s) listed above and should 
> be maintained in strictest confidence. If you are not the intended 
> recipient, you are hereby notified that any disclosure, copying, 
> distribution, or use of the information contained herein (including 
> any reliance thereon) is STRICTLY PROHIBITED. If you have received 
> this e-mail in error, please immediately notify the sender and delete 
> this information from your computer and destroy any related paper 
> copies. Unless otherwise expressly stated in the text of the e-mail, 
> the addition of a typed name or initials to this e-mail does not (i) 
> evidence an intent to sign the e-mail or (ii) constitute either (a) a 
> signature or (b) consent to use electronic records or signatures in 
> place of a writing or a handwritten signature
>
>
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20140703/969178e9/attachment.htm>


More information about the testing-in-python mailing list