boB Stepp wrote: > W7 64-bit. Py 3.4.3 > > unittest result: > > E:\Projects\mcm>python -m unittest > E > ====================================================================== > ERROR: test.db.test_mcm_db_mgr (unittest.loader.ModuleImportFailure) > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "C:\Python34\lib\unittest\case.py", line 58, in testPartExecutor > yield > File "C:\Python34\lib\unittest\case.py", line 577, in run > testMethod() > File "C:\Python34\lib\unittest\loader.py", line 32, in testFailure > raise exception > ImportError: Failed to import test module: test.db.test_mcm_db_mgr > Traceback (most recent call last): > File "C:\Python34\lib\unittest\loader.py", line 312, in _find_tests > module = self._get_module_from_name(name) > File "C:\Python34\lib\unittest\loader.py", line 290, in > _get_module_from_name > __import__(name) > File "E:\Projects\mcm\test\db\test_mcm_db_mgr.py", line 22, in <module> > import mcm_db_mgr > ImportError: No module named 'mcm_db_mgr' > > > ---------------------------------------------------------------------- > Ran 1 test in 0.000s > > FAILED (errors=1) > > Relevant code in test_mcm_db_mgr.py: > > import unittest > > # import modules to be tested: > import mcm_db_mgr > > class MCMDBMgrTestCase(unittest.TestCase): > def setUp(self): > # Insert setup code here... > pass > > def test_open_mcm_db(self): > pass > > def tearDown(self): > # Insert tear-down code here... > pass > > > I suspect that there is something wrong with my project structure. > Currently it is as follows: > > Projects/ > --mcm/ > ----.git/ > ----doc/ > ----src/ > ------db/ > --------__init__.py > --------mcm_db_mgr.py > ------ui/ > --------__init__.py > ----test/ > ------db/ > --------__init__.py > --------test_mcm_db_mgr.py > ------ui/ > --------__init__.py > ----.gitignore > ----LICENSE.txt > ----README.txt > > All __init__.py files are currently empty. Alex had asked a question > very similar to this situation, and I thought I had understood the > answer Laura had given, but apparently I do not understand. Where am > I going wrong this time?
Assuming E:/Projects/mcm/src is in the PYTHONPATH mcm_db_mgr.py (what an alphabet soup!) is part of your db package and has to be imported with import db.mcm_db_mgr or from db import mcm_db_mgr by modules outside the db package. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor