How do I pass variables declared from the python command line to the testcase instance? Edit: a and b are inputs to the method func().
a = [1,2,3]
b = np.array([1,2])
Filename: code.py
import unittest
import numpy as np
def func(a,b)
c = a*b
return (c)
class TestCases(unittest.TestCase):
def test_length_a_equals_length_b(self):
self.assertEqual(len(a), len(b), msg="len(a) != len(b)")
How would I input a and b into the test case, so an error occurs when they are not the same length?
I get the following error when I run the file from terminal:
ERROR: test_a_len_equals_len_b (main.TestCases)
----------------------------------------------------------------------
Traceback (most recent call last):
File "code.py", in test_length_a_equals_length_b
self.assertEqual(len(a), len(b), msg="len(a) != len(b)")
NameError: global name 'a' is not defined