Example #1
0
def start():
    global pulsar
    argv = sys.argv
    if len(argv) > 1 and argv[1] == 'nose':
        pulsar = None
        sys.argv.pop(1)

    if pulsar:
        from pulsar.apps.test import TestSuite
        from pulsar.apps.test.plugins import bench, profile

        os.environ['stdnet_test_suite'] = 'pulsar'
        suite = TestSuite(description='Dynts Asynchronous test suite',
                          plugins=(
                              profile.Profile(),
                              bench.BenchMark(),
                          ))
        suite.start()
    elif nose:
        os.environ['stdnet_test_suite'] = 'nose'
        argv = list(sys.argv)
        noseoption(argv, '-w', value='tests/regression')
        noseoption(argv, '--all-modules')
        nose.main(argv=argv, addplugins=[NoseHttpProxy()])
    else:
        print('To run tests you need either pulsar or nose.')
        exit(0)
Example #2
0
def start(argv=None, modules=None, nose_options=None, description=None,
          version=None, plugins=None):
    '''Start djpcms tests. Use this function to start tests for
djpcms aor djpcms applications. It check for pulsar and nose
and add testing plugins.'''
    use_nose = False
    argv = argv or sys.argv
    description = description or 'Djpcms Asynchronous test suite'
    version = version or djpcms.__version__
    if len(argv) > 1 and argv[1] == 'nose':
        use_nose = True
        sys.argv.pop(1)
    if use_nose:
        os.environ['djpcms_test_suite'] = 'nose'
        if stdnet_test and plugins is None:
            plugins = [stdnet_test.NoseStdnetServer()]
        argv = list(argv)
        if nose_options:
            nose_options(argv)
        nose.main(argv=argv, addplugins=plugins)
    else:
        os.environ['djpcms_test_suite'] = 'pulsar'
        from pulsar.apps.test import TestSuite
        from pulsar.apps.test.plugins import bench, profile
        if stdnet_test and plugins is None:
            plugins = (stdnet_test.PulsarStdnetServer(),
                       bench.BenchMark(),
                       profile.Profile())
        suite = TestSuite(modules=modules,
                          plugins=plugins,
                          description=description,
                          version=version)
        suite.start()
Example #3
0
 def test_profile_plugin(self):
     from pulsar.apps.test.plugins import profile
     p = profile.Profile()
     p.config.set('profile', True)
     p.configure(p.config)
     p.profile_temp_path = tempfile.mkdtemp()
     self.assertFalse(p.on_end())
     shutil.rmtree(p.profile_temp_path)
     #
     lines = list(profile.data_stream(['', 'a b c d e f']))
     self.assertEqual(lines, [])
Example #4
0
def runtests(**params):
    import pulsar
    from pulsar.apps.test import TestSuite
    from pulsar.apps.test.plugins import bench, profile
    import pulsar.utils.settings.backend
    #
    TestSuite(description='Pulsar Asynchronous test suite',
              modules=('tests',
                       ('examples', 'tests'),
                       ('examples', 'test_*')),
              plugins=(bench.BenchMark(),
                       profile.Profile()),
              pidfile='test.pid',
              **params).start()
Example #5
0
def runtests(**params):
    from pulsar.apps.test import TestSuite
    from pulsar.apps.test.plugins import bench, profile
    import pulsar.utils.settings.backend  # noqa

    djangopath = os.path.join(os.path.dirname(__file__), 'examples', 'djchat')
    if djangopath not in sys.path:
        sys.path.append(djangopath)
    #
    TestSuite(description='Pulsar Asynchronous test suite',
              modules=('tests', ('examples', 'tests'), ('examples', 'test_*')),
              plugins=(bench.BenchMark(), profile.Profile()),
              pidfile='test.pid',
              **params).start()
Example #6
0
def runtests(**params):
    import lux
    suite = TestSuite(description='Lux Asynchronous test suite',
                      version=lux.__version__,
                      modules=['tests'],
                      plugins=(bench.BenchMark(),
                               profile.Profile()),
                      pidfile='test.pid',
                      **params).start()
    #
    if suite.cfg.coveralls:
        from pulsar.utils.cov import coveralls
        coveralls(strip_dirs=strip_dirs,
                  stream=suite.stream,
                  repo_token='CNw6W9flYDDXZYeStmR1FX9F4vo0MKnyX')
Example #7
0
def runtests(**params):
    import stdnet
    from stdnet.utils import test
    #
    strip_dirs = [Path(stdnet.__file__).parent.parent, os.getcwd()]
    #
    suite = TestSuite(description='Stdnet Asynchronous test suite',
                      modules=('tests.all', ),
                      plugins=(test.StdnetPlugin(), bench.BenchMark(),
                               profile.Profile()),
                      **params)
    suite.bind_event('tests', test.create_tests)
    suite.start()
    #
    if suite.cfg.coveralls:
        from pulsar.utils.cov import coveralls
        coveralls(strip_dirs=strip_dirs,
                  stream=suite.stream,
                  repo_token='ZQinNe5XNbzQ44xYGTljP8R89jrQ5xTKB')
Example #8
0
def runtests():
    from pulsar.apps.test import TestSuite
    from pulsar.apps.test.plugins import bench, profile

    args = sys.argv
    if '--coveralls' in args:
        import lux
        from pulsar.utils.path import Path
        from pulsar.apps.test.cov import coveralls

        repo_token = None
        strip_dirs = [Path(lux.__file__).parent.parent, os.getcwd()]
        if os.path.isfile('.coveralls-repo-token'):
            with open('.coveralls-repo-token') as f:
                repo_token = f.read().strip()
        coveralls(strip_dirs=strip_dirs, repo_token=repo_token)
        sys.exit(0)
    #
    TestSuite(description='Lux Asynchronous test suite',
              modules=['tests'],
              test_timeout=30,
              thread_workers=2,
              plugins=(bench.BenchMark(), profile.Profile())).start()
Example #9
0
def runtests(cov=None, **params):
    import pulsar
    from pulsar.utils.path import Path
    from pulsar.apps.test import TestSuite
    from pulsar.apps.test.plugins import bench, profile
    import pulsar.utils.settings.backend
    #
    path = Path(__file__)
    path.add2python('stdnet', 1, down=['python-stdnet'], must_exist=False)
    strip_dirs = [Path(pulsar.__file__).parent.parent, os.getcwd()]
    #
    suite = TestSuite(description='Pulsar Asynchronous test suite',
                      modules=('tests', ('examples', 'tests'), ('examples',
                                                                'test_*')),
                      plugins=(bench.BenchMark(), profile.Profile()),
                      pidfile='test.pid',
                      **params).start()
    #
    if suite.cfg.coveralls:
        from pulsar.utils.cov import coveralls
        coveralls(strip_dirs=strip_dirs,
                  stream=suite.stream,
                  repo_token='CNw6W9flYDDXZYeStmR1FX9F4vo0MKnyX')
Example #10
0
def run():
    from pulsar.apps.test import TestSuite
    from pulsar.apps.test.plugins import bench, profile

    args = sys.argv
    if '--coveralls' in args:
        import cloud
        from pulsar.utils.path import Path
        from pulsar.apps.test.cov import coveralls

        repo_token = None
        strip_dirs = [Path(cloud.__file__).parent.parent, os.getcwd()]
        if os.path.isfile('.coveralls-repo-token'):
            with open('.coveralls-repo-token') as f:
                repo_token = f.read().strip()
        coveralls(strip_dirs=strip_dirs, repo_token=repo_token)
        sys.exit(0)
    # Run the test suite
    #
    TestSuite(description='pulsar-pusher asynchronous test suite',
              modules=['tests'],
              plugins=(bench.BenchMark(), profile.Profile()),
              test_timeout=30,
              config='config.py').start()
Example #11
0
 def test_profile_plugins(self):
     suite = TestSuite(plugins=[profile.Profile()])
     self.assertTrue(suite.cfg.plugins)
     self.assertTrue('profile' in suite.cfg.settings)
     self.assertTrue('profile_stats_path' in suite.cfg.settings)