Function with *args type param causes invalid test code

5 views
Skip to first unread message

ssteinerX

unread,
Oct 2, 2009, 2:12:04 PM10/2/09
to Pythoscope
Hi!
I'm new to Pythonscope and am using it to generate some tests for
the first time.

One of my functions has the signature:

def build_url(*params):
pass

When I called the function with a list, like so, in a points-of-
entry file, the following test code was generated:

def test_build_url_returns_thisisa_for_tuple(self):
self.assertEqual('this/is/a', build_url(params=('', 'this',
'is', 'a')))

Unfortunately, using a keyword parameter like that causes this:

ERROR: test_build_url_returns_thisisatest_for_tuple
(wssw_urlutils.tests.test_url_util.TestBuildUrl)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/ssteiner/.../test_url_util.py", line 29, in
test_build_url_returns_thisisatest_for_tuple
self.assertEqual('this/is/a/test', build_url(params=((' this ',
' \r\nis \r\n', '\t\r\n a\r\n\t', ' test '),)))
TypeError: build_url() got an unexpected keyword argument 'params'

So...is this a known issue and, is there a work-around?

Thanks,

S

Michał Kwiatkowski

unread,
Oct 2, 2009, 2:32:12 PM10/2/09
to pytho...@googlegroups.com

That's a bug and it wasn't known until now. :-) Now tracking on
https://bugs.launchpad.net/pythoscope/+bug/440773

For now I would suggest to manually (or rather - using your favourite
editor ;-) get rid of those params=(...), so your tests pass.

Cheers,
mk

sste...@gmail.com

unread,
Oct 2, 2009, 5:14:46 PM10/2/09
to pytho...@googlegroups.com

On Oct 2, 2009, at 2:32 PM, Michał Kwiatkowski wrote:

>
> On Fri, Oct 2, 2009 at 8:12 PM, ssteinerX <sste...@gmail.com> wrote:
>> One of my functions has the signature:
>>
>> def build_url(*params):
>> pass
>>
>> When I called the function with a list, like so, in a points-of-
>> entry file, the following test code was generated:
>>
>> def test_build_url_returns_thisisa_for_tuple(self):
>> self.assertEqual('this/is/a', build_url(params=('', 'this',
>> 'is', 'a')))
>>
>> Unfortunately, using a keyword parameter like that causes this:
>>
>> ERROR: test_build_url_returns_thisisatest_for_tuple
>> (wssw_urlutils.tests.test_url_util.TestBuildUrl)
>> ----------------------------------------------------------------------
>> Traceback (most recent call last):
>> File "/Users/ssteiner/.../test_url_util.py", line 29, in
>> test_build_url_returns_thisisatest_for_tuple
>> self.assertEqual('this/is/a/test', build_url(params=((' this ',
>> ' \r\nis \r\n', '\t\r\n a\r\n\t', ' test '),)))
>> TypeError: build_url() got an unexpected keyword argument 'params'
>>
>> So...is this a known issue and, is there a work-around?
>
> That's a bug and it wasn't known until now. :-) Now tracking on
> https://bugs.launchpad.net/pythoscope/+bug/440773

Cool. Want my test case?

> For now I would suggest to manually (or rather - using your favourite
> editor ;-) get rid of those params=(...), so your tests pass.

That's what I did, thanks.

S

Michał Kwiatkowski

unread,
Oct 10, 2009, 12:23:23 PM10/10/09
to pytho...@googlegroups.com
On Fri, Oct 2, 2009 at 11:14 PM, sste...@gmail.com
<sste...@gmail.com> wrote:
> On Oct 2, 2009, at 2:32 PM, Michał Kwiatkowski wrote:
>> That's a bug and it wasn't known until now. :-) Now tracking on
>> https://bugs.launchpad.net/pythoscope/+bug/440773
>
> Cool.  Want my test case?

The sample code you provided was enough to reproduce the problem.

Issue is now fixed in trunk, thanks again for the report!

Cheers,
mk

Reply all
Reply to author
Forward
0 new messages