[Twisted-Python] Subproject releases

Glyph Lefkowitz glyph at divmod.com
Tue Oct 18 20:03:25 EDT 2005

On Tue, 2005-10-18 at 00:04 -0400, James Y Knight wrote:
> On Oct 12, 2005, at 10:29 PM, Glyph Lefkowitz wrote:
> > Hmm.  Trial interaction is something I haven't messed with yet; I
> > haven't put trial directory below a __path__ entry.
> >
> > Arguably this is simply a bug in Trial that should be fixed, though.

[snip explanation]

> So, my solution:
> I changed the recursive process to actually import every package (not  
> every module!), so it can use the package's __path__ attribute to  
> find submodules. This works, mostly.

Well, thanks for fixing that bug :).  Is there any issue for this
somewhere already, before I file one?

> One issue is that it causes trial to emit an import error message  
> from trying to import twisted.internet.iocpreactor and  
> twisted.internet.serialport (because they aren't importable on my  
> system). This is necessary -- trial does not know they don't have a  
> __path__ attribute before importing them, so it has no way of telling  
> that they don't have test modules hidden inside. It would similarly  
> be a bad idea to simply ignore all import errors of packages, as then  
> real errors may be silenced. This could be simply solvable via a  
> special attribute like "no_tests_in_packages= ['iocpreactor',  
> 'serialport']" to twisted/internet/__init__ so trial knows not to  
> bother trying to import those.

That sounds like a good solution to an unfortunate problem.  I notice
that the practice used in iocp and serialport is standardized in the
coding standard (and I probably put it there); is there *any* better way
to do module-level promotions?  Really the way things like that should
work should be a __getattr__ on the module or something, so that you
don't do unnecessary imports.

> The other issue is that test files expecting to be imported as  
> modules _still_ won't work if specified by filename. But, I think  
> that's just a fact of life -- it is not possible in general to do the  
> correct back conversion. AFAICT we will just have to accept this  
> slight functionality loss and recommend that everybody specify module  
> names rather than file names (at least for running twisted's tests --  
> it's only broken when filenameToModuleName is wrong). Also, Trial  
> *does* run the file specified even if it can't figure out how to  
> import it, so if the test code doesn't actually depend on having its  
> real module name (e.g. it doesn't use things like relative imports or  
> __name__), it will also still work.

While we're at this, should we also be talking about running unit tests
which are packaged within zipfiles?  It seems like some of the same
problems might be addressed, as long as we are suggesting that
specifying filenames for tests is not a good idea.

I'm more interested in testing the actual code packaged in zipfiles than
running the tests from there, but it seems like having the whole package
zipped up would be an interesting meta-test case.

More information about the Twisted-Python mailing list