I am thinking of creating some subclassed Django model fields and distributing them as a package on PyPI. I like to write unit tests for my code (à la TDD), but I'm a bit puzzled as to how I'd write tests for this particular library.
The first thought that came to my mind was to create a Django project that makes use of my subclasses and just use the Django test tools, but that doesn't seem very elegant at all. There's got to be a better way!
Is there a method of somehow bootstrapping Django for this type of thing? I'd appreciate someone pointing me in the right direction. Thanks!
Django itself comes with some tests for field-subclassing; the tests have their own models.py
where the custom fields are used. You should get the best impression when you have a look at the actual code yourself!
Addition: To have the models defined in your test
package being discovered by django you will have to add your yourapp.test
package to INSTALLED_APPS
.
Django itself has a built-in mechanism for its own tests to be automatically discovered and added to INSTALLED_APPS
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With