当前位置: 首页>>代码示例>>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;未经允许,请勿转载。