On Thu, Aug 20, 2015 at 10:13 PM, Steven D'Aprano <st...@pearwood.info> wrote: > On Thu, Aug 20, 2015 at 09:01:50PM -0500, boB Stepp wrote: > > >> import unittest >> >> # import modules to be tested: >> import mcm.db.manager >> >> class ManagerTestCase(unittest.TestCase): >> def setUp(self): >> # Insert setup code here... >> pass >> >> def test_open_db(self): >> pass >> >> def tearDown(self): >> # Insert tear-down code here... >> pass >> >> #if __name__ == "__main__": >> # unittest.main() > > > The two commented out lines at the end would, if uncommented, run > unittest.main() if and only if you are running this specific module as a > thread. In other words, if you were to run: > > python /path/to/the/test.py > > then __name__ would be set to the string "__main__", the if clause would > trigger, and unittest.main() would run. Since those lines are commented > out, that cannot happen.
Okay, I uncommented those two lines and got: E:\Projects\mcm>py -m unittest ./mcm/test/db/test_manager.py Traceback (most recent call last): File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main "__main__", mod_spec) File "C:\Python34\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Python34\lib\unittest\__main__.py", line 18, in <module> main(module=None) File "C:\Python34\lib\unittest\main.py", line 92, in __init__ self.parseArgs(argv) File "C:\Python34\lib\unittest\main.py", line 139, in parseArgs self.createTests() File "C:\Python34\lib\unittest\main.py", line 146, in createTests self.module) File "C:\Python34\lib\unittest\loader.py", line 146, in loadTestsFromNames suites = [self.loadTestsFromName(name, module) for name in names] File "C:\Python34\lib\unittest\loader.py", line 146, in <listcomp> suites = [self.loadTestsFromName(name, module) for name in names] File "C:\Python34\lib\unittest\loader.py", line 105, in loadTestsFromName module = __import__('.'.join(parts_copy)) ValueError: Empty module name Now what? Scratching my sleepy head... boB _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor