[Tutor] import and unittest
thomas coopman
thomas.coopman at gmail.com
Tue Jan 16 15:27:18 CET 2007
On Tue, 16 Jan 2007 10:06:37 -0000
"Alan Gauld" <alan.gauld at btinternet.com> wrote:
>
> "Thomas Coopman" <thomas.coopman at gmail.com> 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 think I will use something like this.
>
> > 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.
>
>
Thanks.
More information about the Tutor
mailing list