Skip to content

Commit

Permalink
Provide discovery-only version of nose2.main (nose2.discover) [Fixes n…
Browse files Browse the repository at this point in the history
…ose-devs#32]

nose2.main is now analagous to unittest.main -- for use in single modules.
nose2.discover is analagous to unit2 discover and is now called by the
nose2 command line script and setuptools scripts.
  • Loading branch information
jpellerin committed Mar 22, 2012
1 parent 583ab37 commit 5c34fa3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions bin/nose2
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

__unittest = True

from nose2.main import main_
from nose2 import discover

main_()
discover()
2 changes: 1 addition & 1 deletion nose2/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from nose2.main import main_
from nose2.main import discover, main
4 changes: 2 additions & 2 deletions nose2/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

__unittest = True

from nose2.main import main_
main_()
from nose2 import discover
discover()
11 changes: 6 additions & 5 deletions nose2/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,6 @@ def loadPlugins(self):

def createTests(self):
"""Create top-level test suite"""
# XXX belongs in init?
if self.module and '__unittest' in dir(self.module):
self.module = None

event = events.CreateTestsEvent(
self.testLoader, self.testNames, self.module)
result = self.session.hooks.createTests(event)
Expand All @@ -244,4 +240,9 @@ def _makeRunner(self):
return event.runner


main_ = PluggableTestProgram
main = PluggableTestProgram


def discover(*args, **kwargs):
kwargs['module'] = None
return main(*args, **kwargs)
5 changes: 2 additions & 3 deletions nose2/tests/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import tempfile
import shutil
import sys
import subprocess

import six

from nose2.compat import unittest
from nose2 import main, util
from nose2 import discover, util


HERE = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -167,7 +166,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
def communicate(self):
with self:
try:
self.result = main.PluggableTestProgram(
self.result = discover(
argv=('nose2',) + self.args, exit=False,
**self.kwargs)
except SystemExit as e:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@

params['entry_points'] = {
'console_scripts': [
'%s = nose2:main_' % SCRIPT1,
'%s = nose2:main_' % SCRIPT2,
'%s = nose2:discover' % SCRIPT1,
'%s = nose2:discover' % SCRIPT2,
],
}
params['install_requires'] = REQS
Expand Down

0 comments on commit 5c34fa3

Please sign in to comment.