Python: how to create a positive test for procedures?
<p>I have a class with some <code>@staticmethod</code>'s that are procedures, thus they do not return anything / their return type is <code>None</code>.</p>

<p>If they fail during their execution, they throw an <code>Exception</code>.</p>

<p>I want to <code>unittest</code> this class, but I am struggling with designing positive tests.</p>

<p>For negative tests this task is easy:</p>

<pre><code>assertRaises(ValueError, my_static_method(*args))
assertRaises(MyCustomException, my_static_method(*args))
</code></pre>

<p>...but how do I create positive tests? Should I redesign my procedures to always return <code>True</code> after execution, so that I can use <code>assertTrue</code> on them?</p>

<p>If your methods do something, then I'm sure there should be a logic there. Let's consider this dummy example:</p>

<pre><code>cool = None

def my_static_method(something):
    try:
       cool = int(something)
    except ValueError:
       # logs here
</code></pre>

<p>for negative test we have:</p>

<pre><code>assertRaises(ValueError, my_static_method(*args))    
</code></pre>

<p>and for possitive test we can check cool:</p>

<pre><code>assertIsNotNone(cool)
</code></pre>

<p>So you're checking if invoking <code>my_static_method</code> affects on <code>cool</code>.</p>

python unit-testing static-methods assert procedure