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


Python pytest.skip方法代碼示例

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


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

示例1: test_simple_inference

# 需要導入模塊: import pytest [as 別名]
# 或者: from pytest import skip [as 別名]
def test_simple_inference(self):
            if not torch.cuda.is_available():
                import pytest

                pytest.skip('test requires GPU and torch+cuda')

            ori_grad_enabled = torch.is_grad_enabled()
            root_dir = os.path.dirname(os.path.dirname(__name__))
            model_config = os.path.join(
                root_dir, 'configs/mask_rcnn/mask_rcnn_r50_fpn_1x_coco.py')
            detector = MaskRCNNDetector(model_config)
            await detector.init()
            img_path = os.path.join(root_dir, 'demo/demo.jpg')
            bboxes, _ = await detector.apredict(img_path)
            self.assertTrue(bboxes)
            # asy inference detector will hack grad_enabled,
            # so restore here to avoid it to influence other tests
            torch.set_grad_enabled(ori_grad_enabled) 
開發者ID:open-mmlab,項目名稱:mmdetection,代碼行數:20,代碼來源:test_async.py

示例2: smb_real

# 需要導入模塊: import pytest [as 別名]
# 或者: from pytest import skip [as 別名]
def smb_real():
    # for these tests to work the server at SMB_SERVER must support dialect
    # 3.1.1, without this some checks will fail as we test 3.1.1 specific
    # features
    username = os.environ.get('SMB_USER', None)
    password = os.environ.get('SMB_PASSWORD', None)
    server = os.environ.get('SMB_SERVER', None)
    port = os.environ.get('SMB_PORT', 445)
    share = os.environ.get('SMB_SHARE', 'share')

    if username and password and server:
        share = r"\\%s\%s" % (server, share)
        encrypted_share = "%s-encrypted" % share
        return username, password, server, int(port), share, encrypted_share
    else:
        pytest.skip("SMB_USER, SMB_PASSWORD, SMB_PORT, SMB_SHARE, "
                    "environment variables were not set, integration tests "
                    "will be skipped") 
開發者ID:jborean93,項目名稱:smbprotocol,代碼行數:20,代碼來源:conftest.py

示例3: setUp

# 需要導入模塊: import pytest [as 別名]
# 或者: from pytest import skip [as 別名]
def setUp(self):
        if self._should_be_skipped_due_to_version():
            pytest.skip('Test cannot run with Python %s.' % (sys.version.split(' ')[0],))
        missing = []
        for req in self._test_file.options['requires']:
            try:
                __import__(req)
            except ImportError:
                missing.append(req)
        if missing:
            pytest.skip('Requires %s to be present.' % (','.join(missing),))
        if self._test_file.options['except_implementations']:
            implementations = [
                item.strip() for item in
                self._test_file.options['except_implementations'].split(",")
            ]
            implementation = platform.python_implementation()
            if implementation in implementations:
                pytest.skip(
                    'Test cannot run with Python implementation %r'
                    % (implementation, )) 
開發者ID:Shopify,項目名稱:shopify_python,代碼行數:23,代碼來源:test_functional.py

示例4: __init__

# 需要導入模塊: import pytest [as 別名]
# 或者: from pytest import skip [as 別名]
def __init__(self, request):
        if not svnbin:
            py.test.skip("svn binary required")
        if not request.config.option.runslowtests:
            py.test.skip('use --runslowtests to run these tests')

        tmpdir = request.getfuncargvalue("tmpdir")
        repodir = tmpdir.join("repo")
        py.process.cmdexec('svnadmin create %s' % repodir)
        if sys.platform == 'win32':
            repodir = '/' + str(repodir).replace('\\', '/')
        self.repo = py.path.svnurl("file://%s" % repodir)
        if sys.platform == 'win32':
            # remove trailing slash...
            repodir = repodir[1:]
        self.repopath = py.path.local(repodir)
        self.temppath = tmpdir.mkdir("temppath")
        self.auth = SvnAuth('johnny', 'foo', cache_auth=False,
                                    interactive=False)
        make_repo_auth(self.repopath, {'johnny': ('foo', 'rw')})
        self.port, self.pid = serve_bg(self.repopath.dirpath())
        # XXX caching is too global
        py.path.svnurl._lsnorevcache._dict.clear()
        request.addfinalizer(lambda: py.process.kill(self.pid)) 
開發者ID:pytest-dev,項目名稱:py,代碼行數:26,代碼來源:test_svnauth.py

示例5: test_switch

# 需要導入模塊: import pytest [as 別名]
# 或者: from pytest import skip [as 別名]
def test_switch(self, setup):
        import pytest
        try:
            import xdist
            pytest.skip('#160: fails under xdist')
        except ImportError:
            pass
        wc = py.path.svnwc(setup.temppath, auth=setup.auth)
        svnurl = 'svn://localhost:%s/%s' % (setup.port, setup.repopath.basename)
        wc.checkout(svnurl)
        wc.ensure('foo', dir=True).ensure('foo.txt').write('foo')
        wc.commit('added foo dir with foo.txt file')
        wc.ensure('bar', dir=True)
        wc.commit('added bar dir')
        bar = wc.join('bar')
        bar.switch(svnurl + '/foo')
        assert bar.join('foo.txt') 
開發者ID:pytest-dev,項目名稱:py,代碼行數:19,代碼來源:test_svnauth.py

示例6: test_console_log

# 需要導入模塊: import pytest [as 別名]
# 或者: from pytest import skip [as 別名]
def test_console_log(conf, requests_session):
    r = requests_session.get(conf.getoption("server") + "/api/v1/action/")
    r.raise_for_status()
    response = r.json()

    # Verify we have at least one response and then grab the first record
    assert len(response) >= 1

    # Look for any console-log actions
    cl_records = [record for record in response if record["name"] == "console-log"]

    if len(cl_records) == 0:
        pytest.skip("No console-log actions found")
        return

    record = cl_records[0]
    # Does an 'action' have all the required fields?
    expected_action_fields = ["name", "implementation_url", "arguments_schema"]
    for field in record:
        assert field in expected_action_fields

    check_action_schema_format(record) 
開發者ID:mozilla,項目名稱:normandy,代碼行數:24,代碼來源:test_api.py

示例7: test_show_heartbeat

# 需要導入模塊: import pytest [as 別名]
# 或者: from pytest import skip [as 別名]
def test_show_heartbeat(conf, requests_session):
    r = requests_session.get(conf.getoption("server") + "/api/v1/action/")
    r.raise_for_status()
    response = r.json()

    # Verify we have at least one response and then grab the first record
    assert len(response) >= 1

    # Let's find at least one record that is a 'show-heartbeat'
    sh_records = [record for record in response if record["name"] == "show-heartbeat"]

    if len(sh_records) == 0:
        pytest.skip("No show-heartbeat actions found")
        return

    record = sh_records[0]
    expected_action_fields = ["name", "implementation_url", "arguments_schema"]
    for field in record:
        assert field in expected_action_fields

    check_action_schema_format(record) 
開發者ID:mozilla,項目名稱:normandy,代碼行數:23,代碼來源:test_api.py

示例8: test_recipe_history

# 需要導入模塊: import pytest [as 別名]
# 或者: from pytest import skip [as 別名]
def test_recipe_history(conf, requests_session):
    r = requests_session.get(conf.getoption("server") + "/api/v1/recipe/")
    r.raise_for_status()
    data = r.json()

    if len(data) == 0:
        pytest.skip("No recipes found.")

    for item in data:
        endpoint = f'/api/v1/recipe/{item["id"]}/history/'
        r = requests_session.get(conf.getoption("server") + endpoint)
        r.raise_for_status()
        history = r.json()

        last_date = datetime.now()
        for revision in history:
            created = datetime.strptime(revision["date_created"], "%Y-%m-%dT%H:%M:%S.%fZ")
            assert created < last_date
            last_date = created 
開發者ID:mozilla,項目名稱:normandy,代碼行數:21,代碼來源:test_api.py

示例9: test_recipe_read

# 需要導入模塊: import pytest [as 別名]
# 或者: from pytest import skip [as 別名]
def test_recipe_read(conf, requests_session):
    # Get random recipe and make sure it's valid
    response = requests_session.get(urljoin(conf.getoption("server"), "/api/v3/recipe/"))
    data = response.json()

    if len(data["results"]) == 0:
        pytest.skip("Could not find any recipes")

    element = randint(0, len(data["results"]) - 1)
    recipe_id = data["results"][element]["id"]
    response = requests_session.get(
        urljoin(conf.getoption("server"), "/api/v3/recipe/{}".format(recipe_id))
    )
    data = response.json()
    assert response.status_code != 404
    assert_valid_schema(response.json()) 
開發者ID:mozilla,項目名稱:normandy,代碼行數:18,代碼來源:test_recipe_read.py

示例10: test_get_data_user_stage

# 需要導入模塊: import pytest [as 別名]
# 或者: from pytest import skip [as 別名]
def test_get_data_user_stage(is_public_test, tmpdir, conn_cnx, db_parameters):
    """SNOW-20927: Tests Get failure with 404 error."""
    if is_public_test or 'AWS_ACCESS_KEY_ID' not in os.environ:
        pytest.skip('This test requires to change the internal parameter')

    default_s3bucket = os.getenv('SF_AWS_USER_BUCKET',
                                 "sfc-dev1-regression/{}/reg".format(
                                     getuser()))
    test_data = [
        {
            's3location':
                '{}/{}'.format(
                    default_s3bucket, db_parameters['name'] + '_stage'),
            'stage_name': db_parameters['name'] + '_stage1',
            'data_file_name': 'data.txt',
        },
    ]
    for elem in test_data:
        _put_list_rm_files_in_stage(tmpdir, conn_cnx, db_parameters, elem) 
開發者ID:snowflakedb,項目名稱:snowflake-connector-python,代碼行數:21,代碼來源:test_put_get_user_stage.py

示例11: test_run_mutation_trials_good_binop

# 需要導入模塊: import pytest [as 別名]
# 或者: from pytest import skip [as 別名]
def test_run_mutation_trials_good_binop(
    bos, bod, exp_trials, parallel, single_binop_file_with_good_test, change_to_tmp
):
    """Slow test to run detection trials on a simple mutation on a binop.

    Based on fixture, there is one Add operation, with 6 substitutions e.g.
    sub, div, mult, pow, mod, floordiv, therefore, 6 total trials are expected for a full run
    and 1 trial is expected when break on detected is used.

    Args:
        bos: break on survival
        bod: break on detection
        exp_trials: number of expected trials
        single_binop_file_with_good_test: fixture for single op with a good test
    """
    if sys.version_info < (3, 8) and parallel:
        pytest.skip("Under version 3.8 will not run parallel tests.")

    test_cmds = f"pytest {single_binop_file_with_good_test.test_file.resolve()}".split()

    config = Config(
        n_locations=100, break_on_survival=bos, break_on_detected=bod, multi_processing=parallel
    )

    results_summary = run.run_mutation_trials(
        single_binop_file_with_good_test.src_file.resolve(), test_cmds=test_cmds, config=config
    )

    assert len(results_summary.results) == exp_trials

    # in all trials the status should be detected
    for mutant_trial in results_summary.results:
        assert mutant_trial.return_code == 1
        assert mutant_trial.status == "DETECTED" 
開發者ID:EvanKepner,項目名稱:mutatest,代碼行數:36,代碼來源:test_run.py

示例12: test_run_mutation_trials_bad_binop

# 需要導入模塊: import pytest [as 別名]
# 或者: from pytest import skip [as 別名]
def test_run_mutation_trials_bad_binop(
    bos, bod, exp_trials, parallel, single_binop_file_with_bad_test, change_to_tmp
):
    """Slow test to run detection trials on a simple mutation on a binop.

    Based on fixture, there is one Add operation, with 6 substitutions e.g.
    sub, div, mult, pow, mod, floordiv, therefore, 6 total trials are expected for a full run
    and 1 trial is expected when break on detected is used.

    Args:
        bos: break on survival
        bod: break on detection
        exp_trials: number of expected trials
        single_binop_file_with_good_test: fixture for single op with a good test
    """
    if sys.version_info < (3, 8) and parallel:
        pytest.skip("Under version 3.8 will not run parallel tests.")

    test_cmds = f"pytest {single_binop_file_with_bad_test.test_file.resolve()}".split()

    config = Config(
        n_locations=100, break_on_survival=bos, break_on_detected=bod, multi_processing=parallel
    )

    results_summary = run.run_mutation_trials(
        single_binop_file_with_bad_test.src_file.resolve(), test_cmds=test_cmds, config=config
    )

    assert len(results_summary.results) == exp_trials

    # in all trials the status should be survivors
    for mutant_trial in results_summary.results:
        assert mutant_trial.return_code == 0
        assert mutant_trial.status == "SURVIVED" 
開發者ID:EvanKepner,項目名稱:mutatest,代碼行數:36,代碼來源:test_run.py

示例13: _check_unicode_filesystem

# 需要導入模塊: import pytest [as 別名]
# 或者: from pytest import skip [as 別名]
def _check_unicode_filesystem(tmpdir):
    filename = tmpdir / ntou('☃', 'utf-8')
    tmpl = 'File system encoding ({encoding}) cannot support unicode filenames'
    msg = tmpl.format(encoding=sys.getfilesystemencoding())
    try:
        io.open(str(filename), 'w').close()
    except UnicodeEncodeError:
        pytest.skip(msg) 
開發者ID:cherrypy,項目名稱:cherrypy,代碼行數:10,代碼來源:test_static.py

示例14: test_file_stream_deadlock

# 需要導入模塊: import pytest [as 別名]
# 或者: from pytest import skip [as 別名]
def test_file_stream_deadlock(self):
        if cherrypy.server.protocol_version != 'HTTP/1.1':
            return self.skip()

        self.PROTOCOL = 'HTTP/1.1'

        # Make an initial request but abort early.
        self.persistent = True
        conn = self.HTTP_CONN
        conn.putrequest('GET', '/bigfile', skip_host=True)
        conn.putheader('Host', self.HOST)
        conn.endheaders()
        response = conn.response_class(conn.sock, method='GET')
        response.begin()
        self.assertEqual(response.status, 200)
        body = response.fp.read(65536)
        if body != b'x' * len(body):
            self.fail("Body != 'x' * %d. Got %r instead (%d bytes)." %
                      (65536, body[:50], len(body)))
        response.close()
        conn.close()

        # Make a second request, which should fetch the whole file.
        self.persistent = False
        self.getPage('/bigfile')
        if self.body != b'x' * BIGFILE_SIZE:
            self.fail("Body != 'x' * %d. Got %r instead (%d bytes)." %
                      (BIGFILE_SIZE, self.body[:50], len(body))) 
開發者ID:cherrypy,項目名稱:cherrypy,代碼行數:30,代碼來源:test_static.py

示例15: skip

# 需要導入模塊: import pytest [as 別名]
# 或者: from pytest import skip [as 別名]
def skip(self, msg='skipped '):
        pytest.skip(msg) 
開發者ID:cherrypy,項目名稱:cherrypy,代碼行數:4,代碼來源:helper.py


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