V
V
Valery Ryaboshapko2015-09-09 09:40:34
Python
Valery Ryaboshapko, 2015-09-09 09:40:34

How to test a validator in an abstract class?

There is an abstract class, it has a setter that calls the private validator function. The validator returns False or True, in case of False the setter throws a ValueError exception.
What is the correct way to write a test for this validator?
If it’s more or less clear with checking for invalid data (there is unittest.assertRaises()), then I can’t figure out how to check for correct execution on valid data.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
angru, 2015-09-09
@valerium

well, what are you? :)

def success_test(self):
    a = ABC()
    a.foo = 10
    self.assertEqual(a.foo, 10)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question