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


Python pytest.deprecated_call方法代码示例

本文整理汇总了Python中pytest.deprecated_call方法的典型用法代码示例。如果您正苦于以下问题:Python pytest.deprecated_call方法的具体用法?Python pytest.deprecated_call怎么用?Python pytest.deprecated_call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pytest的用法示例。


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

示例1: deprecated_test

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import deprecated_call [as 别名]
def deprecated_test(test: Callable) -> Callable:
    """Marks a test as using deprecated functionality.

    Ensures the test is executed within the `pytest.deprecated_call()` context.

    Args:
        test: The test.

    Returns:
        The decorated test.
    """

    @functools.wraps(test)
    def decorated_test(*args, **kwargs) -> Any:
        with pytest.deprecated_call():
            test(*args, **kwargs)

    return decorated_test 
开发者ID:quantumlib,项目名称:OpenFermion-Cirq,代码行数:20,代码来源:_compat_test.py

示例2: _make_client_document

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import deprecated_call [as 别名]
def _make_client_document(firestore_api, testcase):
    from google.cloud.firestore_v1beta1 import Client
    from google.cloud.firestore_v1beta1.client import DEFAULT_DATABASE
    import google.auth.credentials

    _, project, _, database, _, doc_path = testcase.doc_ref_path.split("/", 5)
    assert database == DEFAULT_DATABASE

    # Attach the fake GAPIC to a real client.
    credentials = mock.Mock(spec=google.auth.credentials.Credentials)

    with pytest.deprecated_call():
        client = Client(project=project, credentials=credentials)

    client._firestore_api_internal = firestore_api
    return client, client.document(doc_path) 
开发者ID:googleapis,项目名称:python-firestore,代码行数:18,代码来源:test_cross_language.py

示例3: test___database_string_property

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import deprecated_call [as 别名]
def test___database_string_property(self):
        credentials = _make_credentials()
        database = "cheeeeez"

        with pytest.deprecated_call():
            client = self._make_one(
                project=self.PROJECT, credentials=credentials, database=database
            )

        self.assertIsNone(client._database_string_internal)
        database_string = client._database_string
        expected = "projects/{}/databases/{}".format(client.project, client._database)
        self.assertEqual(database_string, expected)
        self.assertIs(database_string, client._database_string_internal)

        # Swap it out with a unique value to verify it is cached.
        client._database_string_internal = mock.sentinel.cached
        self.assertIs(client._database_string, mock.sentinel.cached) 
开发者ID:googleapis,项目名称:python-firestore,代码行数:20,代码来源:test_client.py

示例4: test_collection_factory_nested

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import deprecated_call [as 别名]
def test_collection_factory_nested(self):
        from google.cloud.firestore_v1beta1.collection import CollectionReference

        with pytest.deprecated_call():
            client = self._make_default_one()

        parts = ("users", "alovelace", "beep")
        collection_path = "/".join(parts)
        collection1 = client.collection(collection_path)

        self.assertEqual(collection1._path, parts)
        self.assertIs(collection1._client, client)
        self.assertIsInstance(collection1, CollectionReference)

        # Make sure using segments gives the same result.
        collection2 = client.collection(*parts)
        self.assertEqual(collection2._path, parts)
        self.assertIs(collection2._client, client)
        self.assertIsInstance(collection2, CollectionReference) 
开发者ID:googleapis,项目名称:python-firestore,代码行数:21,代码来源:test_client.py

示例5: test_document_factory

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import deprecated_call [as 别名]
def test_document_factory(self):
        from google.cloud.firestore_v1beta1.document import DocumentReference

        parts = ("rooms", "roomA")

        with pytest.deprecated_call():
            client = self._make_default_one()

        doc_path = "/".join(parts)
        document1 = client.document(doc_path)

        self.assertEqual(document1._path, parts)
        self.assertIs(document1._client, client)
        self.assertIsInstance(document1, DocumentReference)

        # Make sure using segments gives the same result.
        document2 = client.document(*parts)
        self.assertEqual(document2._path, parts)
        self.assertIs(document2._client, client)
        self.assertIsInstance(document2, DocumentReference) 
开发者ID:googleapis,项目名称:python-firestore,代码行数:22,代码来源:test_client.py

示例6: test_document_factory_nested

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import deprecated_call [as 别名]
def test_document_factory_nested(self):
        from google.cloud.firestore_v1beta1.document import DocumentReference

        with pytest.deprecated_call():
            client = self._make_default_one()

        parts = ("rooms", "roomA", "shoes", "dressy")
        doc_path = "/".join(parts)
        document1 = client.document(doc_path)

        self.assertEqual(document1._path, parts)
        self.assertIs(document1._client, client)
        self.assertIsInstance(document1, DocumentReference)

        # Make sure using segments gives the same result.
        document2 = client.document(*parts)
        self.assertEqual(document2._path, parts)
        self.assertIs(document2._client, client)
        self.assertIsInstance(document2, DocumentReference) 
开发者ID:googleapis,项目名称:python-firestore,代码行数:21,代码来源:test_client.py

示例7: test_index

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import deprecated_call [as 别名]
def test_index(self):
        self.call('python -m signac init my_project'.split())
        self.call('python -m signac project --access'.split())
        project = signac.Project()
        project.open_job({'a': 0}).init()
        assert len(project) == 1
        with pytest.deprecated_call():
            assert len(list(project.index())) == 1
            assert len(list(signac.index())) == 1
        doc = json.loads(self.call('python -m signac index'.split()))
        assert 'statepoint' in doc
        assert doc['statepoint'] == {'a': 0}
        doc = json.loads(self.call('python -m signac project --index'.split()))
        assert 'statepoint' in doc
        assert doc['statepoint'] == {'a': 0}
        project.open_job({'a': 0}).document['b'] = 0
        doc = json.loads(self.call('python -m signac index'.split()))
        assert 'statepoint' in doc
        assert doc['statepoint'] == {'a': 0}
        assert 'b' in doc
        assert doc['b'] == 0 
开发者ID:glotzerlab,项目名称:signac,代码行数:23,代码来源:test_shell.py

示例8: test_regex_file_crawler_pre_compiled

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import deprecated_call [as 别名]
def test_regex_file_crawler_pre_compiled(self):
        self.setup_project()

        class Crawler(indexing.RegexFileCrawler):
            pass

        regex = re.compile(r".*a_(?P<a>\d)\.txt")
        with pytest.deprecated_call():
            Crawler.define(regex, TestFormat)
        crawler = Crawler(root=self._tmp_dir.name)
        no_find = True
        with pytest.deprecated_call():
            for doc in crawler.crawl():
                no_find = False
                ffn = os.path.join(doc['root'], doc['filename'])
                m = regex.match(ffn)
                assert m is not None
                assert os.path.isfile(ffn)
                with open(ffn) as file:
                    doc2 = json.load(file)
                    assert doc2['a'] == doc['a']
        assert not no_find 
开发者ID:glotzerlab,项目名称:signac,代码行数:24,代码来源:test_indexing.py

示例9: test_master_crawler

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import deprecated_call [as 别名]
def test_master_crawler(self):
        self.setup_project()
        crawler = indexing.MasterCrawler(root=self._tmp_dir.name)
        crawler.tags = {'test1'}
        no_find = True
        with pytest.deprecated_call():
            for doc in crawler.crawl():
                no_find = False
                ffn = os.path.join(doc['root'], doc['filename'])
                assert os.path.isfile(ffn)
                with open(ffn) as file:
                    doc2 = json.load(file)
                    assert doc2['a'] == doc['a']
                with signac.fetch(doc) as file:
                    pass
        assert not no_find 
开发者ID:glotzerlab,项目名称:signac,代码行数:18,代码来源:test_indexing.py

示例10: test_index

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import deprecated_call [as 别名]
def test_index(self):
        self.setup_project()
        root = self._tmp_dir.name
        with pytest.deprecated_call():
            assert len(list(signac.index(root=root))) == 0
            index = signac.index(root=self._tmp_dir.name, tags={'test1'})
        no_find = True
        for doc in index:
            no_find = False
            ffn = os.path.join(doc['root'], doc['filename'])
            assert os.path.isfile(ffn)
            with open(ffn) as file:
                doc2 = json.load(file)
                assert doc2['a'] == doc['a']
            with pytest.deprecated_call():
                with signac.fetch(doc) as file:
                    pass
        assert not no_find 
开发者ID:glotzerlab,项目名称:signac,代码行数:20,代码来源:test_indexing.py

示例11: test_fetch

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import deprecated_call [as 别名]
def test_fetch(self):
        with pytest.deprecated_call():
            with pytest.raises(ValueError):
                signac.fetch(None)
            with pytest.raises(errors.FetchError):
                signac.fetch(dict())
        self.setup_project()
        crawler = indexing.MasterCrawler(root=self._tmp_dir.name)
        crawler.tags = {'test1'}
        with pytest.deprecated_call():
            docs = list(crawler.crawl())
        assert len(docs) == 2
        for doc in docs:
            with pytest.deprecated_call():
                with signac.fetch(doc) as file:
                    pass
        with pytest.deprecated_call():
            for doc, file in indexing.fetched(docs):
                doc2 = json.load(file)
                assert doc['a'] == doc2['a']
                file.close() 
开发者ID:glotzerlab,项目名称:signac,代码行数:23,代码来源:test_indexing.py

示例12: test_export_to_mirror

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import deprecated_call [as 别名]
def test_export_to_mirror(self):
        self.setup_project()
        crawler = indexing.MasterCrawler(root=self._tmp_dir.name)
        crawler.tags = {'test1'}
        index = self.get_index_collection()
        mirror = _TestFS()
        with pytest.deprecated_call():
            for doc in crawler.crawl():
                assert 'file_id' in doc
                doc.pop('file_id')
                with pytest.raises(errors.ExportError):
                    signac.export_to_mirror(doc, mirror)
                break
            for doc in crawler.crawl():
                assert 'file_id' in doc
                signac.export_one(doc, index)

                signac.export_to_mirror(doc, mirror)
            assert index.replace_one.called
            for doc in crawler.crawl():
                assert index.find_one({'_id': doc['_id']}) is not None
                with mirror.get(doc['file_id']):
                    pass 
开发者ID:glotzerlab,项目名称:signac,代码行数:25,代码来源:test_indexing.py

示例13: test_master_crawler_tags

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import deprecated_call [as 别名]
def test_master_crawler_tags(self):
        self.setup_project()
        crawler = indexing.MasterCrawler(root=self._tmp_dir.name)
        with pytest.deprecated_call():
            assert 0 == len(list(crawler.crawl()))
            crawler.tags = None
            assert 0 == len(list(crawler.crawl()))
            crawler.tags = {}
            assert 0 == len(list(crawler.crawl()))
            crawler.tags = {'nomatch'}
            assert 0 == len(list(crawler.crawl()))
            crawler.tags = {'test1'}
            assert 2 == len(list(crawler.crawl()))
            crawler.tags = {'test2'}
            assert 2 == len(list(crawler.crawl()))
            crawler.tags = {'test1', 'test2'}
            assert 2 == len(list(crawler.crawl()))
            crawler.tags = {'test1', 'non-existent-key'}
            assert 2 == len(list(crawler.crawl()))
            crawler.tags = {'test2', 'non-existent-key'}
            assert 2 == len(list(crawler.crawl()))
            crawler.tags = {'test1', 'test2', 'non-existent-key'}
            assert 2 == len(list(crawler.crawl())) 
开发者ID:glotzerlab,项目名称:signac,代码行数:25,代码来源:test_indexing.py

示例14: test_export_custom_path_function

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import deprecated_call [as 别名]
def test_export_custom_path_function(self):
        prefix_data = os.path.join(self._tmp_dir.name, 'data')
        for i in range(10):
            self.project.open_job(dict(a=i)).init()
        with pytest.deprecated_call():
            ids_before_export = list(sorted(self.project.find_job_ids()))

        with pytest.raises(RuntimeError):
            self.project.export_to(target=prefix_data, path=lambda job: 'non_unique')

        self.project.export_to(
            target=prefix_data, path=lambda job: os.path.join('my_a', str(job.sp.a)))

        assert len(self.project) == 10
        assert len(os.listdir(prefix_data)) == 1
        assert len(os.listdir(os.path.join(prefix_data, 'my_a'))) == 10
        for i in range(10):
            assert os.path.isdir(os.path.join(prefix_data, 'my_a', str(i)))
        with pytest.deprecated_call():
            assert ids_before_export == list(sorted(self.project.find_job_ids())) 
开发者ID:glotzerlab,项目名称:signac,代码行数:22,代码来源:test_project.py

示例15: test_export_import_tarfile

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import deprecated_call [as 别名]
def test_export_import_tarfile(self):
        target = os.path.join(self._tmp_dir.name, 'data.tar')
        for i in range(10):
            self.project.open_job(dict(a=i)).init()
        with pytest.deprecated_call():
            ids_before_export = list(sorted(self.project.find_job_ids()))
        self.project.export_to(target=target)
        assert len(self.project) == 10
        with TarFile(name=target) as tarfile:
            for i in range(10):
                assert 'a/{}'.format(i) in tarfile.getnames()
        os.replace(self.project.workspace(), self.project.workspace() + '~')
        assert len(self.project) == 0
        self.project.import_from(origin=target)
        assert len(self.project) == 10
        with pytest.deprecated_call():
            assert ids_before_export == list(sorted(self.project.find_job_ids())) 
开发者ID:glotzerlab,项目名称:signac,代码行数:19,代码来源:test_project.py


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