Python pytest.deprecated_call() Examples
The following are 30
code examples of pytest.deprecated_call().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pytest
, or try the search function
.
Example #1
Source File: test_indexing.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #2
Source File: test_indexing.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
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()))
Example #3
Source File: test_indexing.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #4
Source File: _compat_test.py From OpenFermion-Cirq with Apache License 2.0 | 6 votes |
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
Example #5
Source File: test_job.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_reset_statepoint_project(self): key = 'move_job' d = testdata() src = test_token dst = dict(test_token) dst['dst'] = True src_job = self.open_job(src) with self.open_data(src_job): src_job.data[key] = d assert key in src_job.data assert len(src_job.data) == 1 with pytest.deprecated_call(): self.project.reset_statepoint(src_job, dst) src_job = self.open_job(src) dst_job = self.open_job(dst) with self.open_data(dst_job): assert key in dst_job.data assert len(dst_job.data) == 1 with self.open_data(src_job): assert key not in src_job.data with pytest.deprecated_call(): with pytest.raises(RuntimeError): self.project.reset_statepoint(src_job, dst) with pytest.raises(DestinationExistsError): self.project.reset_statepoint(src_job, dst)
Example #6
Source File: test_project.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
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()))
Example #7
Source File: test_indexing.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
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()
Example #8
Source File: test_indexing.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #9
Source File: test_project.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_export_import_simple_path_schema_from_path_float(self): prefix_data = os.path.join(self._tmp_dir.name, 'data') for i in range(10): self.project.open_job(dict(a=float(i))).init() with pytest.deprecated_call(): ids_before_export = list(sorted(self.project.find_job_ids())) self.project.export_to(target=prefix_data, copytree=os.replace) assert len(self.project) == 0 assert len(os.listdir(prefix_data)) == 1 assert len(os.listdir(os.path.join(prefix_data, 'a'))) == 10 for i in range(10): assert os.path.isdir(os.path.join(prefix_data, 'a', str(float(i)))) ret = self.project.import_from(origin=prefix_data, schema='a/{a:int}') assert len(ret) == 0 # should not match ret = self.project.import_from(origin=prefix_data, schema='a/{a:float}') assert len(ret) == 10 with pytest.deprecated_call(): assert ids_before_export == list(sorted(self.project.find_job_ids()))
Example #10
Source File: test_project.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_export_import_simple_path_schema_from_path(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())) self.project.export_to(target=prefix_data, copytree=os.replace) assert len(self.project) == 0 assert len(os.listdir(prefix_data)) == 1 assert len(os.listdir(os.path.join(prefix_data, 'a'))) == 10 for i in range(10): assert os.path.isdir(os.path.join(prefix_data, 'a', str(i))) ret = self.project.import_from(origin=prefix_data, schema='a/{a:int}') assert len(ret) == 10 with pytest.deprecated_call(): assert ids_before_export == list(sorted(self.project.find_job_ids()))
Example #11
Source File: test_project.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_export_import_complex_path(self): prefix_data = os.path.join(self._tmp_dir.name, 'data') sp_0 = [{'a': i, 'b': i % 3} for i in range(5)] sp_1 = [{'a': i, 'b': i % 3, 'c': {'a': i, 'b': 0}} for i in range(5)] sp_2 = [{'a': i, 'b': i % 3, 'c': {'a': i, 'b': 0, 'c': {'a': i, 'b': 0}}} for i in range(5)] statepoints = sp_0 + sp_1 + sp_2 for sp in statepoints: self.project.open_job(sp).init() with pytest.deprecated_call(): ids_before_export = list(sorted(self.project.find_job_ids())) self.project.export_to(target=prefix_data, copytree=os.replace) assert len(self.project) == 0 self.project.import_from(prefix_data) assert len(self.project) == len(statepoints) with pytest.deprecated_call(): assert ids_before_export == list(sorted(self.project.find_job_ids()))
Example #12
Source File: test_project.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_export_import_simple_path_with_float(self): prefix_data = os.path.join(self._tmp_dir.name, 'data') for i in range(10): self.project.open_job(dict(a=float(i))).init() with pytest.deprecated_call(): ids_before_export = list(sorted(self.project.find_job_ids())) self.project.export_to(target=prefix_data, copytree=os.replace) assert len(self.project) == 0 assert len(os.listdir(prefix_data)) == 1 assert len(os.listdir(os.path.join(prefix_data, 'a'))) == 10 for i in range(10): assert os.path.isdir(os.path.join(prefix_data, 'a', str(float(i)))) assert len(self.project.import_from(prefix_data)) == 10 assert len(self.project) == 10 with pytest.deprecated_call(): assert ids_before_export == list(sorted(self.project.find_job_ids()))
Example #13
Source File: test_project.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_export_import_schema_callable(self): def my_schema(path): re_sep = re.escape(os.path.sep) m = re.match(r'.*' + re_sep + 'a' + re_sep + r'(?P<a>\d+)$', path) if m: return dict(a=int(m.groupdict()['a'])) 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())) self.project.export_to(target=prefix_data, copytree=os.replace) assert len(self.project.import_from(prefix_data, schema=my_schema)) == 10 with pytest.deprecated_call(): assert ids_before_export == list(sorted(self.project.find_job_ids()))
Example #14
Source File: test_project.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_export_import_simple_path(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())) self.project.export_to(target=prefix_data, copytree=os.replace) assert len(self.project) == 0 assert len(os.listdir(prefix_data)) == 1 assert len(os.listdir(os.path.join(prefix_data, 'a'))) == 10 for i in range(10): assert os.path.isdir(os.path.join(prefix_data, 'a', str(i))) with pytest.raises(StatepointParsingError): self.project.import_from(origin=prefix_data, schema='a/{b:int}') assert len(self.project.import_from(prefix_data)) == 10 assert len(self.project) == 10 with pytest.deprecated_call(): assert ids_before_export == list(sorted(self.project.find_job_ids()))
Example #15
Source File: test_cross_language.py From python-firestore with Apache License 2.0 | 6 votes |
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)
Example #16
Source File: test_project.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_export_import_conflict_synced_with_args(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())) self.project.export_to(target=prefix_data) with pytest.raises(DestinationExistsError): assert len(self.project.import_from(prefix_data)) == 10 selection = list(self.project.find_jobs(dict(a=0))) os.replace(self.project.workspace(), self.project.workspace() + '~') assert len(self.project) == 0 assert len(self.project.import_from(prefix_data, sync=dict(selection=selection))) == 10 assert len(self.project) == 1 assert len(self.project.find_jobs(dict(a=0))) == 1 with pytest.deprecated_call(): assert list(self.project.find_job_ids())[0] in ids_before_export
Example #17
Source File: test_project.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_export_import_conflict_synced(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())) self.project.export_to(target=prefix_data) with pytest.raises(DestinationExistsError): assert len(self.project.import_from(prefix_data)) == 10 with self.project.temporary_project() as tmp_project: assert len(tmp_project.import_from(prefix_data)) == 10 assert len(tmp_project) == 10 self.project.sync(tmp_project) with pytest.deprecated_call(): assert ids_before_export == list(sorted(self.project.find_job_ids())) assert len(self.project.import_from(prefix_data, sync=True)) == 10 with pytest.deprecated_call(): assert ids_before_export == list(sorted(self.project.find_job_ids()))
Example #18
Source File: test_indexing.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #19
Source File: test_client.py From python-firestore with Apache License 2.0 | 6 votes |
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)
Example #20
Source File: test_project.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_export_import_zipfile(self): target = os.path.join(self._tmp_dir.name, 'data.zip') for i in range(10): with self.project.open_job(dict(a=i)) as job: os.makedirs(job.fn('sub-dir')) with open(job.fn(os.path.join('sub-dir', 'signac_statepoint.json')), 'w') as file: file.write(json.dumps({"foo": 0})) 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 ZipFile(target) as zipfile: for i in range(10): assert 'a/{}/signac_statepoint.json'.format(i) in zipfile.namelist() assert 'a/{}/sub-dir/signac_statepoint.json'.format(i) in zipfile.namelist() 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())) for job in self.project: assert job.isfile(os.path.join('sub-dir', 'signac_statepoint.json'))
Example #21
Source File: test_client.py From python-firestore with Apache License 2.0 | 6 votes |
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)
Example #22
Source File: test_client.py From python-firestore with Apache License 2.0 | 6 votes |
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)
Example #23
Source File: test_client.py From python-firestore with Apache License 2.0 | 6 votes |
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)
Example #24
Source File: test_project.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_export_import_tarfile_zipped(self): target = os.path.join(self._tmp_dir.name, 'data.tar.gz') for i in range(10): with self.project.open_job(dict(a=i)) as job: os.makedirs(job.fn('sub-dir')) with open(job.fn(os.path.join('sub-dir', 'signac_statepoint.json')), 'w') as file: file.write(json.dumps({"foo": 0})) 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.open(name=target, mode='r:gz') as tarfile: for i in range(10): assert 'a/{}'.format(i) in tarfile.getnames() assert 'a/{}/sub-dir/signac_statepoint.json'.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())) for job in self.project: assert job.isfile(os.path.join('sub-dir', 'signac_statepoint.json'))
Example #25
Source File: test_project.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
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()))
Example #26
Source File: test_shell.py From signac with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #27
Source File: test_project.py From signac with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_export(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())) self.project.export_to(target=prefix_data) assert len(self.project) == 10 assert len(os.listdir(prefix_data)) == 1 assert len(os.listdir(os.path.join(prefix_data, 'a'))) == 10 for i in range(10): assert os.path.isdir(os.path.join(prefix_data, 'a', str(i))) with pytest.deprecated_call(): assert ids_before_export == list(sorted(self.project.find_job_ids()))
Example #28
Source File: test_project.py From signac with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_schema_subset(self): for i in range(5): self.project.open_job(dict(a=i)).init() s_sub = self.project.detect_schema() for i in range(10): self.project.open_job(dict(a=i)).init() assert s_sub != self.project.detect_schema() s = self.project.detect_schema(subset=self.project.find_jobs({'a.$lt': 5})) assert s == s_sub with pytest.deprecated_call(): s = self.project.detect_schema(subset=self.project.find_job_ids({'a.$lt': 5})) assert s == s_sub
Example #29
Source File: test_project.py From signac with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_export_custom_path_string_modify_flat_flat(self): prefix_data = os.path.join(self._tmp_dir.name, 'data') for i in range(10): for j in range(2): for k in range(2): for l in range(2): self.project.open_job(dict(a=i, b=j, c=k, d=l)).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='non_unique') self.project.export_to(target=prefix_data, path='c_{c}_b_{b}/{{auto:_}}') assert len(self.project) == 80 assert len(os.listdir(prefix_data)) == 4 # self.assertEqual(len(os.listdir(os.path.join(prefix_data, 'a'))), 10) for i in range(10): for j in range(2): for k in range(2): for l in range(2): assert os.path.isdir(os.path.join( prefix_data, 'c_%d_b_%d' % (k, j), 'd_%d_a_%d' % (l, i))) with pytest.deprecated_call(): assert ids_before_export == list(sorted(self.project.find_job_ids()))
Example #30
Source File: test_indexing.py From signac with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_export_with_update(self): self.setup_project() with pytest.deprecated_call(): index = list(signac.index(root=self._tmp_dir.name, tags={'test1'})) collection = self.get_index_collection() with pytest.deprecated_call(): signac.export(index, collection, update=True) assert collection.replace_one.called or collection.bulk_write.called for doc in index: assert collection.find_one({'_id': doc['_id']}) is not None collection.reset_mock() assert len(index) == collection.find().count() assert collection.find.called with pytest.deprecated_call(): signac.export(index, collection, update=True) assert collection.replace_one.called or collection.bulk_write.called for doc in index: assert collection.find_one({'_id': doc['_id']}) is not None assert len(index) == collection.find().count() collection.reset_mock() for fn in ('a_0.txt', 'a_1.txt'): os.remove(os.path.join(self._tmp_dir.name, fn)) N = len(index) with pytest.deprecated_call(): index = list(signac.index(root=self._tmp_dir.name, tags={'test1'})) assert len(index) == (N - 1) collection.reset_mock() if index: with pytest.deprecated_call(): signac.export(index, collection, update=True) assert collection.replace_one.called or collection.bulk_write.called assert len(index) == collection.find().count() else: with pytest.raises(errors.ExportError): with pytest.deprecated_call(): signac.export(index, collection, update=True)