Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support 'test_suite' function convention from Zope #17

Open
jpellerin opened this issue Dec 14, 2011 · 8 comments
Open

Support 'test_suite' function convention from Zope #17

jpellerin opened this issue Dec 14, 2011 · 8 comments
Assignees

Comments

@jpellerin
Copy link
Member

Many Zope developers are used to the 'test_suite function' convention from
Zope, so you can find several packages in PyPI that have all sorts of
styles of tests from unittest to doctest and use the test_suite convention.

An example here:

http://svn.plone.org/svn/plone/plone.i18n/trunk/plone/i18n/normalizer/tests
/test_normalizer.py

In cases like this, nose should by default ignore anything but
the 'test_suite' function, and call the test_suite function to get a
unittest.TestSuite instance back with the tests for that module.

If time permits I will prototype this as a nose plugin, but would be a
nice-to-have feature, specially if we could use the 'nose.collector'
setuptools test_suite shortcut to run tests on that package for example.

Google Code Info:
Issue #: 102
Author: [email protected]
Created On: 2007-09-24T21:19:10.000Z
Closed On:

@ghost ghost assigned jpellerin Dec 14, 2011
@jpellerin
Copy link
Member Author

Here's a fix, with tests, for this issue.

Google Code Info:
Author: [email protected]
Created On: 2007-09-25T01:46:01.000Z

@jpellerin
Copy link
Member Author

I think it would be a great idea to support this convention, but not in the core of
nose. It should be a plugin so that it can be optional, since it's a
backwards-incompatible change for users who don't follow the convention.

I'm rejecting the current patch. If you'd like to put the same functionality into a
plugin, I'll accept it for a release after 0.10.0 -- 0.10.0 is closed for new
functionality.

The keys to making it work as a plugin will be to implement wantModule to reject
modules that contain a test_suite function, and loadTestsFromModule with the same
functionality as the patch.

Google Code Info:
Author: [email protected]
Created On: 2007-09-25T14:35:28.000Z

@jpellerin
Copy link
Member Author

While I disagree that it's a backwards-incompatible change, I agree that it's new
functionality and can't be included in 0.10.0.

The patch does not change behaviour unless you have a test_suite() function
defined, which I believe no-one using nose has, otherwise they would have complained
about the lack of the functionality implemented by this patch.

I would go as far as calling it a bugfix, as for the cited example [1] nose does
find the tests defined as functions in the module, but they are interpreted as
unittests, not as doctests. With the patch though, it behaves as test_suite()
explicitly tells it to.

[1]
http://svn.plone.org/svn/plone/plone.i18n/trunk/plone/i18n/normalizer/tests/test_norm
alizer.py

Anyway, I will give it a try at making this a plugin.

My question is, if the plugin is optional, it won't get called if I use
the 'nose.collector' functionality right? If that's the case, it wouldn't be as
useful to me, unfortunately. :(

Google Code Info:
Author: [email protected]
Created On: 2007-09-26T01:44:46.000Z

@jpellerin
Copy link
Member Author

What makes it backwards-incompatible is the unknown number of users who have tests
like this:

def test_suite():
s = SomeKindOfSuite()
s.do_something()
assert s.some_state

who are expecting those to be collected and run as normal tests, not to have special
behavior.

The plugin can still work no matter how nose is called (nosetests or through the
collector), so long as it doesn't implement methods that can't be run under different
test runners. Since this plugin will be a test selection/loading plugin only, it
should work everywhere. If you want to always use it with your project/projects, you
could add a section to your setup.cfg like:

[nosetests]
with_zope_test_suite=1

And the plugin would always be enabled.

Google Code Info:
Author: [email protected]
Created On: 2007-09-26T14:42:31.000Z

@jpellerin
Copy link
Member Author

I could do this, does anyone still care?

Google Code Info:
Author: [email protected]
Created On: 2010-08-02T10:02:19.000Z

@jpellerin
Copy link
Member Author

I would love this addition. I suspect many others who currently use the
zope.testing test runner and would like to experiment with nose would
like it too.

Google Code Info:
Author: [email protected]
Created On: 2010-08-02T12:33:10.000Z

@jpellerin
Copy link
Member Author

This is my first time contributing so please correct me if I'm doing something wrong.

I have a diff that I think completes the objective but I can't get the plugin to install by default for some reason. Maybe someone here can help me with that.

Google Code Info:
Author: [email protected]
Created On: 2010-08-27T11:12:00.000Z

@jpellerin
Copy link
Member Author

(Some of the comments aren't useful; I was experimenting with them to see if they mattered).

Google Code Info:
Author: [email protected]
Created On: 2010-08-27T11:12:53.000Z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant