This is the code:
# mean_var-_std.py
def calculate(list):
if len(list) < 9:
print("List must contain nine numbers.")
raise ValueError
else:
return 0
This is the unit-test:
import unittest
import mean_var_std
# the test case
class UnitTests(unittest.TestCase):
def test_calculate_with_few_digits(self):
self.assertRaisesRegex(ValueError, "List must contain nine numbers.", mean_var_std.calculate, [2,6,2,8,4,0,1,])
if __name__ == "__main__":
unittest.main()
This is the error that I get:
F
======================================================================
FAIL: test_calculate_with_few_digits (test_module.UnitTests)
----------------------------------------------------------------------
ValueError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/runner/fcc-mean-var-std-2/test_module.py", line 8, in test_calculate_with_few_digits
self.assertRaisesRegex(ValueError, "List must contain nine numbers.", mean_var_std.calculate, [2,6,2,8,4,0,1,])
AssertionError: "List must contain nine numbers." does not match ""
----------------------------------------------------------------------
Ran 1 test in 0.004s
FAILED (failures=1)
I don't understand what AssertionError: "List must contain nine numbers." does not match "" means. How can I solve this problem? Thanks in advance.