Adding tests to a patch

0 views
Skip to first unread message

Peter2108

unread,
Aug 26, 2009, 6:49:14 AM8/26/09
to Django users
I'm trying to help fix but #6138. I've done a patch for the code and a
separate test.py module. But someone ('Alex') added a request to
"Please put the tests in the same diff as the patch itself, it is
possible to use svn add locally". I'm at a loss here I'm afraid. The
only way I know to generate a single diff that included a patch to
trunk/django/forms/forms.py and to the trunk/tests/regressiontests/
forms/forms.py is to set up subversion in the 'trunk' folder. But then
can one apply the patch if one does not have all that stuff?

Also where should one place this test - in trunk/tests/
regressiontests/forms/forms.py or in trunk/tests/regressiontests/
forms/error_messages.py or in a separate module even?

I browsed arund the bug list but could not find anything helpful, some
had no tests, some had tests in a separate file, but I could not find
one as a model. I am getting a bit discouraged at the moment.

Thanks for any help,

Peter

Karen Tracey

unread,
Aug 26, 2009, 8:37:43 AM8/26/09
to django...@googlegroups.com
On Wed, Aug 26, 2009 at 6:49 AM, Peter2108 <pe...@monicol.co.uk> wrote:

I'm trying to help fix but #6138. I've done a patch for the code and a
separate test.py module. But someone ('Alex') added a request to
"Please put the tests in the same diff as the patch itself, it is
possible to use svn add locally". I'm at a loss here I'm afraid. The
only way I know to generate a single diff that included a patch to
trunk/django/forms/forms.py  and to the trunk/tests/regressiontests/
forms/forms.py is to set up subversion in the 'trunk' folder. But then
can one apply the patch if one does not have all that stuff?

I don't really understand what you are asking.  I don't know who the "one" is in your last question nor what "all that stuff" is.

Yes, you are expected to generate diffs from the root of trunk, as requested in the third bullet here:

http://docs.djangoproject.com/en/dev/internals/contributing/#patch-style

Anyone regularly contributing or using patches from trac will generally be using an svn checkout of trunk, or a git (or some other DVCS) clone of the same, so I don't understand what the problem is you are concerned with here?

A committer when considering the patch will expect to be able to apply it to the root of the trunk.  If you don't generate diffs from the root, or post multiple diffs to a ticket that need all be applied, then the committer has to figure out which all pieces are supposed to go together and where to put each one.  This is much more likely to result in errors than a single diff generated from the root of the trunk, thus we request single diffs generated from the root of the trunk.
 

Also where should one place this test - in  trunk/tests/
regressiontests/forms/forms.py or in  trunk/tests/regressiontests/
forms/error_messages.py or in a separate module even?

Whichever seems like the best match.  Without looking at the ticket or existing tests too closely, I'd guess the extending the existing error_messages test would be fine.

Karen

Russell Keith-Magee

unread,
Aug 26, 2009, 8:50:08 AM8/26/09
to django...@googlegroups.com
On Wed, Aug 26, 2009 at 6:49 PM, Peter2108<pe...@monicol.co.uk> wrote:
>
> I'm trying to help fix but #6138. I've done a patch for the code and a
> separate test.py module. But someone ('Alex') added a request to
> "Please put the tests in the same diff as the patch itself, it is
> possible to use svn add locally". I'm at a loss here I'm afraid. The
> only way I know to generate a single diff that included a patch to
> trunk/django/forms/forms.py  and to the trunk/tests/regressiontests/
> forms/forms.py is to set up subversion in the 'trunk' folder. But then
> can one apply the patch if one does not have all that stuff?

I'm not sure I understand the source of your confusion.

The Django install instructions indicate that if you want to use the
Django development code, you should have a checkout of the 'trunk'
director i.e.,:

svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk

In this example, django-trunk is a complete checkout of the Django
code, and it is the directory against which you should be generating
your diff.

> Also where should one place this test - in  trunk/tests/
> regressiontests/forms/forms.py or in  trunk/tests/regressiontests/
> forms/error_messages.py or in a separate module even?

Add the patch wherever seems appropriate. Look around for a similar
tests, and put your tests alongside those. If there really is nothing
similar, add a new test module.

However, don't get too hung up on exactly where to put the tests. If
the location you pick isn't ideal, it will get moved by the committer
when your patch is added to trunk. As a patch contributor, the most
important step is to write the test in the first place, and to put it
somewhere so that it can be executed to demonstrate the validity of
your patch.

Yours,
Russ Magee %-)

Peter2108

unread,
Aug 26, 2009, 8:50:48 AM8/26/09
to Django users
Many thanks Karen. The key was "run svn diff from the top-level trunk
directory"
in the docs. Sorry, I should have re-read them!

Should be OK now,

Peter
Reply all
Reply to author
Forward
0 new messages