I am learning to use unittest.

I have written a program that runs as it should.
247 tests give me a satisfactory answer.

I have now added one more test and I get an error which I do not understand.

The two relevant tests are:

 def test_type_capitalsadvanced(self):
        self.assertEqual(type(self.capitalsadvanced), numpy.ndarray)

 def test_zero_in_capitalsadvanced(self):
        self.assertIn(self.capitalsadvanced, 0.0)

The error message is:

Traceback (most recent call last):
File "/Users/sydney/Capital/Capital_with_productivity/Current_Versions/testPOCWP_V2.py", line 320, in test_zero_in_capitalsadvanced
    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

Final output from the tests is :

Ran 247 tests in 1.179s

FAILED (failures=9, errors=1)

The failures all arise from a 'nan'.
It is this problem that I am trying to resolve.

My problem is that the first test tells me correctly that the object capitalsadvanced is a numpy.ndarray. But the second test error message says it is a float.

I should add that the program creates the initial data set by making use of the random function which is given a mean to work with. Thus each test run will be with different input data. But repeated tests show the same errors.

When I run the same tests with predetermined, fixed data I get no errors and no 'nan' errors.

Any guidance will be very welcome.


--
Sydney
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to