Re: [Tutor] Test discovery not locating module to test
boB Stepp wrote: > On Thu, Aug 20, 2015 at 2:37 AM, Peter Otten <__pete...@web.de> wrote: > >> Assuming E:/Projects/mcm/src is in the PYTHONPATH mcm_db_mgr.py (what an >> alphabet soup!)... > > Written out in full, this would be > > montessori_classroom_manager_database_manager.py > Hmm. Perhaps just db_manager.py? How about manager.py? If you increase the nesting level by introducing an mcm toplevel package you can access the module formerly known as db.mcm_db_mgr with import mcm.db.manager or from mcm.db import manager and avoid the mixture of logical "_" and physical "." separators. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Test discovery not locating module to test
On Thu, Aug 20, 2015 at 2:37 AM, Peter Otten <__pete...@web.de> wrote: > Assuming E:/Projects/mcm/src is in the PYTHONPATH mcm_db_mgr.py (what an > alphabet soup!)... Written out in full, this would be montessori_classroom_manager_database_manager.py Hmm. Perhaps just db_manager.py? > ...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. I'm bad! So clear in the morning, so obscure for me just before bed. In my defense, I have intellectually *known* about this, but have not used the standard library much to this point, and this is the first time I have tried this *package* structure of a project, so that aspect is all new to me. Thanks, Peter! boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Test discovery not locating module to test
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 > 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
[Tutor] Test discovery not locating module to test
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 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? TIA! -- boB ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor