What is a method that does not return a value?

What is a method that does not return a value?

Any method declared void doesn’t return a value. It does not need to contain a return statement, but it may do so.

What types of values can be returned by a method?

A return value can be any one of the four variable types: handle, integer, object, or string. The type of value your function returns depends largely on the task it performs.

Which return type must be used if the method does not return any value?

return void
If a method does not return a value, it must be declared to return void . However, the pop() method in the Stack class returns a reference data type: an object. Methods use the return operator to return a value.

How to do unit test on function without return value?

At these days I am driving myself to do a more complete unit test on some core module in my project. Since we always do unit test with methods ‘assertEqual’, ‘assertTrue’ and so on, these methods all require a return value from the function being tested, I am wondering how to do a plain unit test on some function without a return value.

What are the methods of a validator class?

Every validator class contains two methods: is_valid (value), which returns True or False depending on the value, and ensure_valid (value) which checks for a specified value and either does nothing if the value is valid, or throws a specific exception if the value doesn’t match the predefined rules.

How does the rangevalidator Class check a value?

For instance, a RangeValidator class checks whether a value is within the specified range.

Why is there no assert s in the second Test?

Although the second test does its job—fails if the exception is thrown, and succeeds if ensure_valid doesn’t throw anything—the fact that there is no assert s inside looks strange. Someone who reads such code would immediately ask himself why is there a test which appears to be doing nothing.