[Tutor] Do not understand why test is running.

boB Stepp robertvstepp at gmail.com
Fri Aug 21 04:01:50 CEST 2015


I adopted Peter's suggestions (I think!) and now have these two paths
that are pertinent to my questions:

Projects/mcm/mcm/db/manager.py  # The module I am beginning to write tests for.

Projects/mcm/test/db/test_manager.py    # The file for my module tests.

The test code currently is:

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()

Out of curiosity, I changed the last two lines to comments, as I am
still feeling my way around this package structure and how things
work.  I was surprised when I ran my test now:

E:\Projects\mcm>py -m unittest discover -v
test_open_db (test.db.test_manager.ManagerTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.000s

OK

Obviously I was not expecting this!  Why did the test run?  I thought
it would not happen without those final two lines.

-- 
boB


More information about the Tutor mailing list