Basic unittest TestCase
<p>I have written the below code to test a basic unittest case for learning. When I execute the below code. I do not get any output. Could someone let me know what could be issue.</p>

<pre><code>import unittest
  class test123(unittest.TestCase):

    def test1(self):
      print "test1"

 if __name__ == "main":
 x=test123()
 x.test1()
 unittest.main()
</code></pre>

<p>your code should look like this:</p>

<pre><code>import unittest

class test123(unittest.TestCase):
    def test1(self):
        print "test1"


if __name__ == "__main__":
    unittest.main()
</code></pre>

<p>hence it is name and main with two underscores at the start and end, when you change it and run it with your code then you will get an error with using:</p>

<pre><code>x = test123()
x.test1()

ValueError: no such test method in &lt;class '__main__.test123'&gt;: runTest
</code></pre>

python python-unittest