[Tutor] unitest with random inputs
Alan Gauld
alan.gauld at yahoo.co.uk
Wed Jul 19 12:05:58 EDT 2017
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
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list