On May 21, 2010, at 10:58 AM, Manlio Perillo wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Michael Bayer ha scritto:
>> [...]
>>> Is is possible to modify the SQLAlchemy nose plugin in order to be more
>>> cooperative?
>>> As an example by adding an option that will change the wantClass method from
>>> 
>>> if not issubclass(cls, testing.TestBase):
>>>     return False
>>> else:
>>>     if (hasattr(cls, '__whitelist__') and testing.db.name in
>>> cls.__whitelist__):
>>>         return True
>>>     else:
>>>         return not self.__should_skip_for(cls)
>>> 
>>> to something like (not tested):
>>> 
>>> if self.sa_only and not issubclass(cls, testing.TestBase):
>>>     return False
>>> 
>>> if issubclass(cls, testing.TestBase):
>>>     if (hasattr(cls, '__whitelist__') and testing.db.name in
>>> cls.__whitelist__):
>>>         return True
>>>     else:
>>>         return not self.__should_skip_for(cls)
>>> 
>>> # use nose default
>> 
> 
> A precisation.
> 
> The reason I used the sa_only flag is because I assumed there was a
> reason why test cases not derived from testing.TestBase must be ignored.
> 
> If possible, the wantMethod should be something like:
> 
>  if not issubclass(cls, testing.TestBase):
>      # Skip
>      return None
>  else:
>      if (hasattr(cls, '__whitelist__') and testing.db.name in
> cls.__whitelist__):
>          return True
>      else:
>          return not self.__should_skip_for(cls)
> 
> 
> Another problem I found when using SQLAlchemy nose plugin is that
> warnings are configured to raise exceptions, and this is a problem for me.

OK my thought here is that yeah, this is likely a problem for you, but the nose 
plugin currently is not implemented in such a way as to be usable for other 
people's test configurations.     It might be nice for it to be used this way 
but that's not on the current roadmap and could have all kinds of inconvenient 
issues where nose doesn't quite give us enough flexibility to give SQLA what it 
needs while also being completely useable by other projects.   I don't even 
like everything that the nose plugin does right now and I'd like to change it a 
lot further, the way it gets database URLs, the way it runs through multiple 
databases for tests, the way the plugin gets loaded.    All of which would 
break any end user approach that has built upon it directly.   So I'm not 
entirely comfortable with users buliding their external non-SQLA test suites on 
top of it.

Whereas just copying the parts of it you need for your own purposes is a way to 
get what you need - I dont use the Nose plugin directly outside of SQLA myself, 
I do exactly this.

> 
> 
> By the way: what is the reason why testing.Test does not derive from
> unittest.TestCase?

nose doesn't require unittest.   Ideally we would be able to run tests that 
don't derive from any class at all.    I don't usually use a base class for 
tests, its a historical artifact of the fact that SQLA was written against 
unittest originally.   If I were starting over with nose, I'd do things very 
differently.   Since nose has taken a deep dive into the "its author can't 
support it anymore" category, I'm waiting for the next de-facto test library 
(nose2 i think it was called ?) comes out before doing another full refactor of 
the tests, but I'd like it to be nose-like and not unittest-like.





-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to