Note that there are some explanatory texts on larger screens.

plurals
  1. POBasic Python unittest TestSuite Question
    text
    copied!<p>Using Python 2.6, I have a very simple test in a python file in a directory:</p> <pre><code>#mytest.py import unittest class BasicTests(unittest.TestCase): def test_ok(self): self.assertTrue(True) suite = unittest.TestLoader().loadTestsFromTestCase(BasicTests) </code></pre> <p>I change into the directory and run "python -m unittest mytest.suite" and I get the following error:</p> <pre><code>Traceback (most recent call last): File "/usr/lib/python2.6/runpy.py", line 122, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib/python2.6/runpy.py", line 34, in _run_code exec code in run_globals File "/usr/lib/python2.6/unittest.py", line 875, in &lt;module&gt; main(module=None) File "/usr/lib/python2.6/unittest.py", line 816, in __init__ self.parseArgs(argv) File "/usr/lib/python2.6/unittest.py", line 843, in parseArgs self.createTests() File "/usr/lib/python2.6/unittest.py", line 849, in createTests self.module) File "/usr/lib/python2.6/unittest.py", line 613, in loadTestsFromNames suites = [self.loadTestsFromName(name, module) for name in names] File "/usr/lib/python2.6/unittest.py", line 598, in loadTestsFromName test = obj() File "/usr/lib/python2.6/unittest.py", line 464, in __call__ return self.run(*args, **kwds) TypeError: run() takes exactly 2 arguments (1 given) </code></pre> <p>I've tried several variations (such as unittest.makeSuite and unittest.LoadTestFromNames) but they all give me the same basic error. What am I missing? I keep <a href="http://docs.python.org/release/2.6.6/library/unittest.html" rel="nofollow">reading the documentation</a> and I seem to be following the spec.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload