當前位置: 首頁>>代碼示例>>Python>>正文


Python nose.run方法代碼示例

本文整理匯總了Python中nose.run方法的典型用法代碼示例。如果您正苦於以下問題:Python nose.run方法的具體用法?Python nose.run怎麽用?Python nose.run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在nose的用法示例。


在下文中一共展示了nose.run方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: import nose [as 別名]
# 或者: from nose import run [as 別名]
def main():
    argv = [
        "", "--with-coverage",
        (
            "--cover-package="
            "girlfriend.workflow,"
            "girlfriend.data,"
            "girlfriend.util"
        ),
    ]
    for importer, modname, ispkg in pkgutil.walk_packages(
            path=girlfriend.testing.__path__,
            prefix="girlfriend.testing."):
        if ispkg:
            continue
        if modname in excludes:
            continue
        argv.append(modname)
    nose.run(argv=argv) 
開發者ID:chihongze,項目名稱:girlfriend,代碼行數:21,代碼來源:runalltests.py

示例2: test_state_machine_no_callbacks

# 需要導入模塊: import nose [as 別名]
# 或者: from nose import run [as 別名]
def test_state_machine_no_callbacks():
    @acts_as_state_machine
    class Robot():
        name = 'R2-D2'

        sleeping = State(initial=True)
        running = State()
        cleaning = State()

        run = Event(from_states=sleeping, to_state=running)
        cleanup = Event(from_states=running, to_state=cleaning)
        sleep = Event(from_states=(running, cleaning), to_state=sleeping)

    robot = Robot()
    eq_(robot.current_state, 'sleeping')
    assert robot.is_sleeping
    assert not robot.is_running
    robot.run()
    assert robot.is_running
    robot.sleep()
    assert robot.is_sleeping 
開發者ID:jtushman,項目名稱:state_machine,代碼行數:23,代碼來源:tests.py

示例3: test_invalid_state_transition

# 需要導入模塊: import nose [as 別名]
# 或者: from nose import run [as 別名]
def test_invalid_state_transition():
    @acts_as_state_machine
    class Person(mongoengine.Document):
        name = mongoengine.StringField(default='Billy')

        sleeping = State(initial=True)
        running = State()
        cleaning = State()

        run = Event(from_states=sleeping, to_state=running)
        cleanup = Event(from_states=running, to_state=cleaning)
        sleep = Event(from_states=(running, cleaning), to_state=sleeping)

    establish_mongo_connection()
    person = Person()
    person.save()
    assert person.is_sleeping

    #should raise an invalid state exception
    with assert_raises(InvalidStateTransition):
        person.sleep() 
開發者ID:jtushman,項目名稱:state_machine,代碼行數:23,代碼來源:tests.py

示例4: test_before_callback_blocking_transition

# 需要導入模塊: import nose [as 別名]
# 或者: from nose import run [as 別名]
def test_before_callback_blocking_transition():
    @acts_as_state_machine
    class Runner(mongoengine.Document):
        name = mongoengine.StringField(default='Billy')

        sleeping = State(initial=True)
        running = State()
        cleaning = State()

        run = Event(from_states=sleeping, to_state=running)
        cleanup = Event(from_states=running, to_state=cleaning)
        sleep = Event(from_states=(running, cleaning), to_state=sleeping)

        @before('run')
        def check_sneakers(self):
            return False

    establish_mongo_connection()
    runner = Runner()
    runner.save()
    assert runner.is_sleeping
    runner.run()
    assert runner.is_sleeping
    assert not runner.is_running 
開發者ID:jtushman,項目名稱:state_machine,代碼行數:26,代碼來源:tests.py

示例5: makeSuite

# 需要導入模塊: import nose [as 別名]
# 或者: from nose import run [as 別名]
def makeSuite(self):
        """returns a suite object of tests to run (unittest.TestSuite())

        If self.suitepath is None, this must be implemented. The returned suite
        object will be executed with all plugins activated.  It may return
        None.

        Here is an example of a basic suite object you can return ::

            >>> import unittest
            >>> class SomeTest(unittest.TestCase):
            ...     def runTest(self):
            ...         raise ValueError("Now do something, plugin!")
            ...
            >>> unittest.TestSuite([SomeTest()]) # doctest: +ELLIPSIS
            <unittest...TestSuite tests=[<...SomeTest testMethod=runTest>]>

        """
        raise NotImplementedError 
開發者ID:singhj,項目名稱:locality-sensitive-hashing,代碼行數:21,代碼來源:plugintest.py

示例6: marvin_tests

# 需要導入模塊: import nose [as 別名]
# 或者: from nose import run [as 別名]
def marvin_tests(self, tests=None):
        """Run Marvin tests

        :param tests: marvin tests to run
        """
        self.copy_marvin_config()

        # Run marvin tests
        old_path = os.getcwd()
        nose_args = ("nosetests --with-xunit --xunit-file={path}/nosetests.xml "
                     "--with-marvin --marvin-config={config} "
                     "-s -a tags=advanced {tests}".format(path=old_path,
                                                          config=self.marvin_config,
                                                          tests=" ".join(tests)))
        os.chdir("cosmic-core/test/integration")
        print("==> Running tests")
        if self.debug:
            print('==> Nose parameters: %s' % nose_args)
        ret = nose.run(argv=nose_args.split(" "))
        os.chdir(old_path)
        if not ret:
            sys.exit(1)
        sys.exit(0) 
開發者ID:MissionCriticalCloud,項目名稱:bubble-toolkit,代碼行數:25,代碼來源:CI.py

示例7: test_state_machine

# 需要導入模塊: import nose [as 別名]
# 或者: from nose import run [as 別名]
def test_state_machine():
    @acts_as_state_machine
    class Robot():
        name = 'R2-D2'

        sleeping = State(initial=True)
        running = State()
        cleaning = State()

        run = Event(from_states=sleeping, to_state=running)
        cleanup = Event(from_states=running, to_state=cleaning)
        sleep = Event(from_states=(running, cleaning), to_state=sleeping)

        @before('sleep')
        def do_one_thing(self):
            print("{} is sleepy".format(self.name))

        @before('sleep')
        def do_another_thing(self):
            print("{} is REALLY sleepy".format(self.name))

        @after('sleep')
        def snore(self):
            print("Zzzzzzzzzzzz")

        @after('sleep')
        def snore(self):
            print("Zzzzzzzzzzzzzzzzzzzzzz")


    robot = Robot()
    eq_(robot.current_state, 'sleeping')
    assert robot.is_sleeping
    assert not robot.is_running
    robot.run()
    assert robot.is_running
    robot.sleep()
    assert robot.is_sleeping 
開發者ID:jtushman,項目名稱:state_machine,代碼行數:40,代碼來源:tests.py

示例8: test_multiple_machines

# 需要導入模塊: import nose [as 別名]
# 或者: from nose import run [as 別名]
def test_multiple_machines():
    @acts_as_state_machine
    class Person(object):
        sleeping = State(initial=True)
        running = State()
        cleaning = State()

        run = Event(from_states=sleeping, to_state=running)
        cleanup = Event(from_states=running, to_state=cleaning)
        sleep = Event(from_states=(running, cleaning), to_state=sleeping)

        @before('run')
        def on_run(self):
            things_done.append("Person.ran")

    @acts_as_state_machine
    class Dog(object):
        sleeping = State(initial=True)
        running = State()

        run = Event(from_states=sleeping, to_state=running)
        sleep = Event(from_states=(running,), to_state=sleeping)

        @before('run')
        def on_run(self):
            things_done.append("Dog.ran")

    things_done = []
    person = Person()
    dog = Dog()
    eq_(person.current_state, 'sleeping')
    eq_(dog.current_state, 'sleeping')
    assert person.is_sleeping
    assert dog.is_sleeping
    person.run()
    eq_(things_done, ["Person.ran"])

###################################################################################
## SqlAlchemy Tests
################################################################################### 
開發者ID:jtushman,項目名稱:state_machine,代碼行數:42,代碼來源:tests.py

示例9: _test_argv

# 需要導入模塊: import nose [as 別名]
# 或者: from nose import run [as 別名]
def _test_argv(self, label, verbose, extra_argv):
        ''' Generate argv for nosetest command

        Parameters
        ----------
        label : {'fast', 'full', '', attribute identifier}, optional
            see ``test`` docstring
        verbose : int, optional
            Verbosity value for test outputs, in the range 1-10. Default is 1.
        extra_argv : list, optional
            List with any extra arguments to pass to nosetests.

        Returns
        -------
        argv : list
            command line arguments that will be passed to nose
        '''
        argv = [__file__, self.package_path, '-s']
        if label and label != 'full':
            if not isinstance(label, basestring):
                raise TypeError('Selection label should be a string')
            if label == 'fast':
                label = 'not slow'
            argv += ['-A', label]
        argv += ['--verbosity', str(verbose)]

        # When installing with setuptools, and also in some other cases, the
        # test_*.py files end up marked +x executable. Nose, by default, does
        # not run files marked with +x as they might be scripts. However, in
        # our case nose only looks for test_*.py files under the package
        # directory, which should be safe.
        argv += ['--exe']

        if extra_argv:
            argv += extra_argv
        return argv 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:38,代碼來源:nosetester.py

示例10: run_buffered

# 需要導入模塊: import nose [as 別名]
# 或者: from nose import run [as 別名]
def run_buffered(*arg, **kw):
    kw['buffer_all'] = True
    run(*arg, **kw) 
開發者ID:singhj,項目名稱:locality-sensitive-hashing,代碼行數:5,代碼來源:plugintest.py

示例11: run_module_suite

# 需要導入模塊: import nose [as 別名]
# 或者: from nose import run [as 別名]
def run_module_suite(file_to_run = None):
    if file_to_run is None:
        f = sys._getframe(1)
        file_to_run = f.f_locals.get('__file__', None)
        if file_to_run is None:
            raise AssertionError

    import_nose().run(argv=['', file_to_run]) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:10,代碼來源:nosetester.py

示例12: test

# 需要導入模塊: import nose [as 別名]
# 或者: from nose import run [as 別名]
def test(verbosity=1):
    """run the matplotlib test suite"""
    old_backend = rcParams['backend']
    try:
        use('agg')
        import nose
        import nose.plugins.builtin
        from .testing.noseclasses import KnownFailure
        from nose.plugins.manager import PluginManager
        from nose.plugins import multiprocess

        # store the old values before overriding
        plugins = []
        plugins.append( KnownFailure() )
        plugins.extend( [plugin() for plugin in nose.plugins.builtin.plugins] )

        manager = PluginManager(plugins=plugins)
        config = nose.config.Config(verbosity=verbosity, plugins=manager)

        # Nose doesn't automatically instantiate all of the plugins in the
        # child processes, so we have to provide the multiprocess plugin with
        # a list.
        multiprocess._instantiate_plugins = [KnownFailure]

        success = nose.run( defaultTest=default_test_modules,
                            config=config,
                            )
    finally:
        if old_backend.lower() != 'agg':
            use(old_backend)

    return success 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:34,代碼來源:__init__.py

示例13: check_scale_docstring

# 需要導入模塊: import nose [as 別名]
# 或者: from nose import run [as 別名]
def check_scale_docstring(distfn):
    if distfn.__doc__ is not None:
        # Docstrings can be stripped if interpreter is run with -OO
        npt.assert_('scale' not in distfn.__doc__) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:6,代碼來源:test_discrete_basic.py

示例14: _test

# 需要導入模塊: import nose [as 別名]
# 或者: from nose import run [as 別名]
def _test(verbose=False):
        """This would run all unit tests, but nose couldn't be
        imported so the test suite can not run.
        """
        raise ImportError("Could not load nose. Unit tests not available.") 
開發者ID:statlab,項目名稱:permute,代碼行數:7,代碼來源:__init__.py

示例15: _doctest

# 需要導入模塊: import nose [as 別名]
# 或者: from nose import run [as 別名]
def _doctest(verbose=False):
        """This would run all doc tests, but nose couldn't be
        imported so the test suite can not run.
        """
        raise ImportError("Could not load nose. Doctests not available.") 
開發者ID:statlab,項目名稱:permute,代碼行數:7,代碼來源:__init__.py


注:本文中的nose.run方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。