Oh, I totally overlooked that! Thank you.

On Friday, February 6, 2015 at 12:10:15 PM UTC-3, Daniel Roseman wrote:
>
>
>
> On Thursday, 5 February 2015 12:34:51 UTC, João Sampaio wrote:
>>
>> There are 3 Python files attached.
>>
>> I have my URL file attached. I'm using django-rest-framework (in case you 
>> are wondering what the routers are). When I use ./manage.py test with the 
>> first file (file1.py), the tests succeed. When I do the very same thing 
>> with the second file, the tests fail. The only thing changed between the 
>> files is the addition of this code:
>>
>>     def test_update_member_phone_number(self):
>>         member = self.create_national_team_member()
>>
>>         url = reverse(r'nationalteam-member-phone-number',
>>                       kwargs={r'pk': member.id})
>>
>> The error is this one:
>>
>> ======================================================================
>> ERROR: test_update_member_picture (main.tests.test_national_team.
>> NationalTeamTestCase)
>> ----------------------------------------------------------------------
>> Traceback (most recent call last):
>>   File 
>> "/home/jpmelos/devel/ideation_admin/ideation_admin/main/tests/test_national_team.py"
>> , line 177, in test_update_member_picture
>>     kwargs={r'pk': member.id})
>>   File 
>> "/home/jpmelos/devel/ideation_admin/venv/lib/python2.7/site-packages/django/core/urlresolvers.py"
>> , line 551, in reverse
>>     return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, 
>> **kwargs))
>>   File 
>> "/home/jpmelos/devel/ideation_admin/venv/lib/python2.7/site-packages/django/core/urlresolvers.py"
>> , line 468, in _reverse_with_prefix
>>     (lookup_view_s, args, kwargs, len(patterns), patterns))
>>
>> NoReverseMatch: Reverse for 'nationalteam-member-update-picture' with 
>> arguments '()' and keyword arguments '{'pk': 10}' not found. 1 pattern(s) 
>> tried: ['national-team/(?P<pk>\\d)/update_picture/$']
>>
>> As you can see in the exception text, the pattern does seem to match. The 
>> error seems to happen in a test method that is not even related to the one 
>> added to the tests. What is going on? It doesn't make any sense to me. How 
>> come the mere addition of a call to reverse can cause the tests to crash?
>>
>
>
> Your regex does *not* match: it only accepts a single digit for pk, but 
>  you are passing a two-digit number (10). Modify your regexes to `
> (?P<pk>\d+)`.
> --
> DR.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/57699dbc-59ff-4722-85b6-070311e59484%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to