On Tue, 16 Jan 2007 10:06:37 -0000 "Alan Gauld" <[EMAIL PROTECTED]> wrote:
> > "Thomas Coopman" <[EMAIL PROTECTED]> wrote > . > > I wondered if it was possible to do something like this: > > > > src/ > > -a_module/ > > -sub_module/ > > test/ > > -a_module/ > > -sub_module/ > > > > I don;t see any reason why not although its slightly more work. > Personally I tend to keep the tests with the code, but thats > mainly because tools such as editors tend to remember the last > folder opened and its a pain navigating between the two folders. > > The other system I have used(in C++ not Python) is to have > a test folder inside each src folder like: > > src/ > mod1/ > f1.py > test/ > testf1.py > mod2/ > f2.py > f3.py > test/ > testf1.py > testf2.py > > etc. > > This minimises navigation and keeps the tests separate. > Its also relatively easy to filter out the tests when it comes > time to package upp the code for distribution (assuming > you want to lose them!) > > > I have something like this but I don't know how to organize the > > imports in > > the tests and I don't know if this is a good idea. What do you > > think? > > I think in Python you should create a package structure for > your code so that import can find the modules more easily. > But I've never tried this in Python, my Python projects are rarely > big enough to warrant it. > > well, I still have problems with import suppose I have something like this: M/ __init__.py A/ __init__.py One.py B/ __init__.py Two.py One.py #!/usr/bin/python from M.B import Two Two.py #!/usr/bin/python from M.A import One when I try to run One.py or Two.py I get import errors and I don't know how to fix them. I tried to set the __all__ variable in the __init__ files but nothing worked so far. I would like to run the files from anywhere for example. What am I doing wrong? I read the information about modules on python.org (http://www.python.org/doc/2.0.1/tut/node8.html) but I don't find a solution Thanks _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor