Patch django form field for testing
In case you're wondering how to patch Django form field for testing purposes (like URLField that passes local uri: file://...) here's how:
from .forms import ThatForm from django import forms class MyTests(TestCase): def test_pass_url(self): orig_url = ThatForm.base_fields['url'] ThatForm.base_fields['url'] = forms.CharField() # ... do your thing # # and just in case set original field back, # if other tests need it: ThatForm.base_fields['url'] = orig_url
Archives
- February 2016
- October 2015
- September 2015
- July 2013
- June 2013
- April 2013
- March 2013
- December 2011
- November 2011
- July 2011
- June 2011
- February 2010
- September 2009
- March 2009
- February 2009