This is about Python. I am creating a BitCode
class, and the string can only consist of 0's and 1's, if it does not, it will raise a ValueError
with a message.
For example,
b = BitCode('1001')
is valid.
I was wondering after I write:
class Bitcode:
The test part of the code is:
class TestBitCode(unittest.TestCase):
def test_constructor_value_error_bits(self):
with self.assertRaises(ValueError):
b = BitList('FE')
Where can I put the code that checks to make sure the parameter of each object contains only 0 and 1?