[Tutor] unitest with random inputs

Sydney Shall s.shall at virginmedia.com
Wed Jul 19 12:27:56 EDT 2017


On 19/07/2017 18:05, Alan Gauld via Tutor wrote:
> On 19/07/17 16:01, Sydney Shall wrote:
>> I am learning to use unittest.
>>
> 
>>    def test_zero_in_capitalsadvanced(self):
>>           self.assertIn(self.capitalsadvanced, 0.0)
> 
> Remember the interpreter...
> 
> 
>>>> help(unittest.case.assertIn)
> Help on function assertIn in module unittest.case:
> 
> assertIn(self, member, container, msg=None)
>      Just like self.assertTrue(a in b), but with a nicer default message.
> ~
> 
>> The error message is:
>>
>>       self.assertIn(self.capitalsadvanced, 0.0)
>>     File "/Users/sydney/anaconda/lib/python3.6/unittest/case.py", line
>> 1077, in assertIn
>>       if member not in container:
>> TypeError: argument of type 'float' is not iterable
> 
> The obvious float is 0.0
> The likely container is self.capitalsadvanced
> 
> They are reversed according to the help screen.
> 
> HTH
> 
My apologies for giving you extra work. I am in fact a very long sitting 
member of the list. Ever since kindergarden. You taught me to walk.
I used thw wrong email account.

Thanks. Yes, that cures one problem. Also thanks for the guidance. It is 
most useful.

-- 
Sydney


More information about the Tutor mailing list