当前位置: 首页>>代码示例>>Python>>正文


Python nose.with_setup函数代码示例

本文整理汇总了Python中nose.with_setup函数的典型用法代码示例。如果您正苦于以下问题:Python with_setup函数的具体用法?Python with_setup怎么用?Python with_setup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了with_setup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_app_state

def check_app_state(test):
    def checker(when):
        def check_app_state():
            import editxt
            assert not hasattr(editxt, "app"), editxt.app
        return check_app_state
    return with_setup(checker("before"), checker("after"))(test)
开发者ID:editxt,项目名称:editxt,代码行数:7,代码来源:util.py

示例2: check_app_state

def check_app_state(test):
    def checker(when):
        def check_app_state():
            from editxt.application import DocumentController
            dc = DocumentController.sharedDocumentController()
            assert not dc.documents(), "app state was dirty %s %s: %r" \
                % (when, test.__name__, dc.documents())
        return check_app_state
    return with_setup(checker("before"), checker("after"))(test)
开发者ID:youngrok,项目名称:editxt,代码行数:9,代码来源:util.py

示例3: check_skip_travis

import os
from nose import SkipTest, with_setup


def check_skip_travis():
    """Skip test if being run on Travis."""
    if os.environ.get('TRAVIS') == "true":
        raise SkipTest("This test needs to be skipped on Travis")

with_travis = with_setup(check_skip_travis)
开发者ID:samim23,项目名称:dagbldr,代码行数:10,代码来源:test_utils.py

示例4: teardown


def teardown():
    splinter_tests.kill_browser()


def do_logout():
    splinter_tests.visit("/logout")
    splinter_tests.visit("/#/login")
    browser = splinter_tests.browser

    # Wait up to 15 seconds for the page to load
    assert browser.is_element_present_by_css("h1.title", wait_time=15)


logout_before = with_setup(do_logout)


@logout_before
def test_at_login_page():
    """After logout, the user should end up at the login page."""
    browser = splinter_tests.browser

    # Check that we should be at the login page.
    assert_that(browser.url, ends_with("#/login"))

    # Check that "Log in" appears on screen
    assert browser.is_text_present("Log in")
    # Check the title indicates we're at the login page.
    assert_that(browser.title, is_("Login | XBee ZigBee Cloud Kit"))
开发者ID:Rahuldee,项目名称:XBeeZigBeeCloudKit,代码行数:28,代码来源:test_login.py

示例5: Redis

import os
import simplejson
from nose import with_setup
from redis import Redis

redis = Redis(host=os.getenv('REDIS_HOST', 'localhost'), port=int(os.getenv('REDIS_PORT', 6379)),
              db=int(os.getenv('REDIS_DB', 0)))

def assert_queue_entry(json, item, **envelope_keys):
    assert isinstance(json, basestring)
    entry = simplejson.loads(json)
    assert isinstance(entry, dict)
    assert 'ts' in entry
    assert 'first_ts' in entry
    assert 'attempts' in entry
    assert 'v' in entry
    assert 'item' in entry
    assert entry['item'] == item
    for key, value in envelope_keys.iteritems():
        assert entry[key] == value, '{} != {}'.format(entry[key], value)

def assert_error_queue_empty(queue):
    assert not queue.error_queue.errors()

class TestRetryError(Exception):
    pass

clear = with_setup(redis.flushdb)
开发者ID:gamechanger,项目名称:dockets,代码行数:28,代码来源:util.py

示例6: setup_temp_folder

SOME_TEXT_DIGEST = hashlib.md5(SOME_TEXT_CONTENT).hexdigest()


def setup_temp_folder():
    global lcclient, LOCAL_TEST_FOLDER, TEST_WORKSPACE
    LOCAL_TEST_FOLDER = tempfile.mkdtemp('-nuxeo-drive-tests')
    lcclient = LocalClient(LOCAL_TEST_FOLDER)
    TEST_WORKSPACE = lcclient.make_folder('/', 'Some Workspace')


def teardown_temp_folder():
    if os.path.exists(LOCAL_TEST_FOLDER):
        shutil.rmtree(LOCAL_TEST_FOLDER)


with_temp_folder = with_setup(setup_temp_folder, teardown_temp_folder)


@with_temp_folder
def test_make_documents():
    doc_1 = lcclient.make_file(TEST_WORKSPACE, 'Document 1.txt')
    assert_true(lcclient.exists(doc_1))
    assert_equal(lcclient.get_content(doc_1), "")
    doc_1_info = lcclient.get_info(doc_1)
    assert_equal(doc_1_info.name, 'Document 1.txt')
    assert_equal(doc_1_info.path, doc_1)
    assert_equal(doc_1_info.get_digest(), EMPTY_DIGEST)
    assert_equal(doc_1_info.folderish, False)

    doc_2 = lcclient.make_file(TEST_WORKSPACE, 'Document 2.txt',
                              content=SOME_TEXT_CONTENT)
开发者ID:bjalon,项目名称:nuxeo-drive,代码行数:31,代码来源:test_integration_local_client.py

示例7: with_dummy_transmitter_setup

def with_dummy_transmitter_setup(f):
    return with_setup(DummyTestController.start_dummy_streaming_process,
                      DummyTestController.stop_dummy_streaming_process)(f)
开发者ID:Egor-Krivov,项目名称:eegstream,代码行数:3,代码来源:dummy_setup.py

示例8: func

            @wraps(func)
            def func(*args, **kwargs):
                raise SkipTest(message)
        return func
    return decorator


def clean_warning_registry():
    """Safe way to reset warnings """
    warnings.resetwarnings()
    reg = "__warningregistry__"
    for mod_name, mod in list(sys.modules.items()):
        if 'six.moves' in mod_name:
            continue
        if hasattr(mod, reg):
            getattr(mod, reg).clear()


def check_skip_network():
    if int(os.environ.get('SKLEARN_SKIP_NETWORK_TESTS', 0)):
        raise SkipTest("Text tutorial requires large dataset download")


def check_skip_travis():
    """Skip test if being run on Travis."""
    if os.environ.get('TRAVIS') == "true":
        raise SkipTest("This test needs to be skipped on Travis")

with_network = with_setup(check_skip_network)
with_travis = with_setup(check_skip_travis)
开发者ID:DrahmA,项目名称:scikit-learn,代码行数:30,代码来源:testing.py

示例9: teardown_func

from turbogears import testutil
from videostore.controllers import Root
import cherrypy

def teardown_func():
    """Tests for apps using identity need to stop CP/TG after each test to
    stop the VisitManager thread.
    See http://trac.turbogears.org/turbogears/ticket/1217 for details.
    """
    turbogears.startup.stopTurboGears()

cherrypy.root = Root()

def test_method():
    "the index method should return a string called now"
    result = testutil.call(cherrypy.root.index)
    assert type(result["now"]) == type('')
test_method = with_setup(teardown=teardown_func)(test_method)

def test_indextitle():
    "The indexpage should have the right title"
    testutil.createRequest("/")
    assert "<TITLE>Welcome to TurboGears</TITLE>" in cherrypy.response.body[0]
test_indextitle = with_setup(teardown=teardown_func)(test_indextitle)

def test_logintitle():
    "login page should have the right title"
    testutil.createRequest("/login")
    assert "<TITLE>Login</TITLE>" in cherrypy.response.body[0]
test_logintitle = with_setup(teardown=teardown_func)(test_logintitle)
开发者ID:gjhiggins,项目名称:elixir,代码行数:30,代码来源:test_controllers.py

示例10: wrap

 def wrap(f):
     return with_setup(
         lambda: setup(f.__name__) if (setup is not None) else None,
         lambda: teardown(f.__name__) if (teardown is not None) else None)(f)
开发者ID:LubuntuFu,项目名称:minicps,代码行数:4,代码来源:utils.py

示例11: dec

 def dec(f):
     return with_setup(setup, teardown)(f)
开发者ID:aliceinwire,项目名称:lodgeit,代码行数:2,代码来源:runner.py

示例12: log_in

def log_in(*auth):
    delete_all_dashboards(*auth)
    add_empty_dashboard(*auth)

    log_in_clean(*auth)

    splinter_tests.visit("/#/add_widget")

    # Wait a moment for everything to settle
    do_sleep()

    with screenshot_on_exception("log_in_not_add_widget"):
        assert_that(browser.url, ends_with('/#/add_widget'))


log_in_before = with_setup(lambda: log_in("e2e_user", "e2e_password",
                                          "e2e_fqdn"))
log_in_test_before = with_setup(lambda: log_in("test_user", "e2e_password",
                                               "login.etherios.com"))


def is_error_message_present(key, message):
    xpath = ("//div[contains(@class, 'alert alert-danger')]/ul/li"
             "/strong[contains(., '{}')]/..").format(key)
    match = browser.find_by_xpath(xpath)

    # Check that we found a matching error message
    with screenshot_on_exception("find_error_%s" % key):
        assert not match.is_empty(), "No error message for %s" % key

        assert_that(match.first.text, contains_string(message))
开发者ID:Rahuldee,项目名称:XBeeZigBeeCloudKit,代码行数:31,代码来源:test_add_widget_page.py

示例13: Controller

    os.mkdir(LOCAL_NXDRIVE_CONF_FOLDER)

    ctl = Controller(LOCAL_NXDRIVE_CONF_FOLDER)


def teardown_integration_env():
    if ctl is not None:
        ctl.get_session().close()
    if remote_client is not None and remote_client.exists(TEST_WORKSPACE):
        remote_client.delete(TEST_WORKSPACE, use_trash=False)

    if os.path.exists(LOCAL_TEST_FOLDER):
        shutil.rmtree(LOCAL_TEST_FOLDER)


with_integration_env = with_setup(setup_integration_env, teardown_integration_env)


def make_server_tree():
    # create some folders on the server
    folder_1 = remote_client.make_folder(TEST_WORKSPACE, "Folder 1")
    folder_1_1 = remote_client.make_folder(folder_1, "Folder 1.1")
    folder_1_2 = remote_client.make_folder(folder_1, "Folder 1.2")
    folder_2 = remote_client.make_folder(TEST_WORKSPACE, "Folder 2")

    # create some files on the server
    remote_client.make_file(folder_2, "Duplicated File.txt", content="Some content.")
    remote_client.make_file(folder_2, "Duplicated File.txt", content="Other content.")

    remote_client.make_file(folder_1, "File 1.txt", content="aaa")
    remote_client.make_file(folder_1_1, "File 2.txt", content="bbb")
开发者ID:bjalon,项目名称:nuxeo-drive,代码行数:31,代码来源:test_integration_synchronization.py

示例14: setup_db

    global mc_pid
    LOGGER.info("Killing memcached instance running on port %d",
        settings['correlator']['memcached_port'])
    try:
        # Tue le serveur memcached lancé en arrière-plan.
        os.kill(mc_pid, signal.SIGTERM)
        os.wait() # Avoid zombies. Bad zombies.
    except OSError, e:
        # We mostly ignore errors, maybe we should
        # do something more useful here.
        print e
    finally:
        mc_pid = None
    return MemcachedConnection.reset()

with_mc = nose.with_setup(setup_mc, teardown_mc)

#Create an empty database before we start our tests for this module
def setup_db():
    """Crée toutes les tables du modèle dans la BDD."""
    from vigilo.models.tables.grouppath import GroupPath
    from vigilo.models.tables.usersupitem import UserSupItem
    tables = metadata.tables.copy()
    del tables[GroupPath.__tablename__]
    del tables[UserSupItem.__tablename__]
    metadata.create_all(tables=tables.itervalues())
    metadata.create_all(tables=[GroupPath.__table__, UserSupItem.__table__])

#Teardown that database
def teardown_db():
    """Supprime toutes les tables du modèle de la BDD."""
开发者ID:vigilo,项目名称:correlator,代码行数:31,代码来源:helpers.py

示例15: register

def register(fn):
    all_queue_tests.append(with_setup(clear_redis)(fn))
    return fn
开发者ID:gamechanger,项目名称:dockets,代码行数:3,代码来源:basic_queue_test.py


注:本文中的nose.with_setup函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。