def test_generation_ladder_of_orders(highest_bid, lowest_ask, number_of_orders, number_of_ticks_between_orders, expected_ladder_bids, expected_ladder_asks, basic_marketmaker): settings.MARKET_MAKER_NUMBER_ORDERS = number_of_orders settings.MARKET_MAKER_NUMBER_OF_TICKS_BETWEEN_ORDERS = number_of_ticks_between_orders ladder_bids, ladder_asks = basic_marketmaker.generate_order_ladders( highest_bid=highest_bid, lowest_ask=lowest_ask) assert ladder_bids == expected_ladder_bids assert ladder_asks == expected_ladder_asks @pytest.mark.parametrize( 'new_york_orderbook,chicago_orderbook,ladder_bids,ladder_asks,\ expected_trimmed_ladder_bids,expected_trimmed_ladder_asks,set_global_delay', [ (pytest.lazy_fixture('empty_orderbook'), pytest.lazy_fixture('orderbook_with_best_bid_and_no_ask'), [100, 200, 300], [400, 500, 1500], [100, 200, 300], [1500], 0), (pytest.lazy_fixture('empty_orderbook'), pytest.lazy_fixture('orderbook_with_no_bid_and_best_ask'), [500, 1000, 1500], [400, 500, 1500], [], [400, 500, 1500], 0), (pytest.lazy_fixture('empty_orderbook'), pytest.lazy_fixture('empty_orderbook'), [100, 200, 400], [500, 1000, 1500], [100, 200, 400], [500, 1000, 1500], 0), (pytest.lazy_fixture('orderbook_with_normal_bid_and_no_ask'), pytest.lazy_fixture('orderbook_with_no_bid_and_normal_ask'), [], [], [], [], 0), ]) def test_trim_orders_ladder(basic_marketmaker, basic_regulator, new_york_orderbook, chicago_orderbook, ladder_bids, ladder_asks, expected_trimmed_ladder_bids,
name: meta is preserved too """) (tmp_dir / PIPELINE_FILE).write_text(text.format(src="foo", dest="bar")) assert dvc.reproduce(PIPELINE_FILE) assert run_copy("foo1", "bar1", name="copy-foo-bar", force=True) assert (tmp_dir / PIPELINE_FILE).read_text() == text.format(src="foo1", dest="bar1") @pytest.mark.parametrize( "workspace, hash_name, foo_hash, bar_hash", [ ( pytest.lazy_fixture("local_cloud"), "md5", "acbd18db4cc2f85cedef654fccc4a4d8", "37b51d194a7513e45b56f6524f2d51f2", ), pytest.param( pytest.lazy_fixture("ssh"), "md5", "acbd18db4cc2f85cedef654fccc4a4d8", "37b51d194a7513e45b56f6524f2d51f2", marks=pytest.mark.skipif(os.name == "nt", reason="disabled on windows"), ), ( pytest.lazy_fixture("s3"), "etag",
('snake_case', 'snake-case'), ('snake_snake_case', 'snake-snake-case'), ('snake2_snake2_case', 'snake2-snake2-case'), ('snake3_snake3-case', 'snake3-snake3-case'), (' CamelGetHTTPResponse_code_snake2_case is a pain', 'camel-get-http-response-code-snake2-case-is-a-pain') ]) def test_convert_to_kebab(orig, expected): assert expected == yapconf.change_case(orig) @pytest.mark.parametrize('filename,file_type,expected', [ ( 'ascii.yaml', 'yaml', pytest.lazy_fixture('ascii_data') ), ( 'unicode.yaml', 'yaml', pytest.lazy_fixture('unicode_data') ), ( 'ascii.json', 'json', pytest.lazy_fixture('ascii_data') ), ( 'unicode.json', 'json', pytest.lazy_fixture('unicode_data')
def test_compute_after_smooth_goddard_2013(PM_da_initialized_3d_full, PM_da_control_3d_full): """Test compute_perfect_model works after smoothings.""" PM_da_control_3d_full = smooth_goddard_2013(PM_da_control_3d_full) PM_da_initialized_3d_full = smooth_goddard_2013(PM_da_initialized_3d_full) actual = compute_perfect_model(PM_da_initialized_3d_full, PM_da_control_3d_full) north_atlantic = actual.sel(lat=slice(40, 50), lon=slice(-30, -20)) assert not north_atlantic.isnull().any() @pytest.mark.parametrize("smooth", [2, 4]) @pytest.mark.parametrize( "pm", [ pytest.lazy_fixture( "perfectModelEnsemble_initialized_control_1d_ym_cftime"), pytest.lazy_fixture( "perfectModelEnsemble_initialized_control_1d_mm_cftime"), pytest.lazy_fixture( "perfectModelEnsemble_initialized_control_1d_dm_cftime"), ], ) def test_PerfectModelEnsemble_temporal_smoothing_cftime_and_skill(pm, smooth): """Test that PredictionEnsemble.smooth({'lead': int}) aggregates lead.""" pm = pm.isel(lead=range(6)) pm_smoothed = pm.smooth({"lead": smooth}) assert (pm_smoothed.get_initialized().lead.size == pm.get_initialized().lead.size - smooth + 1) assert pm_smoothed._temporally_smoothed skill = pm_smoothed.verify(metric="acc", comparison="m2e",
assert os.path.isfile("file_imported") assert (tmp_dir / "file_imported").read_text() == "contents" def test_get_repo_dir(tmp_dir, erepo_dir): with erepo_dir.chdir(): erepo_dir.dvc_gen({"dir": {"file": "contents"}}, commit="create dir") Repo.get(os.fspath(erepo_dir), "dir", "dir_imported") assert (tmp_dir / "dir_imported").read_text() == {"file": "contents"} @pytest.mark.parametrize( "erepo", [pytest.lazy_fixture("git_dir"), pytest.lazy_fixture("erepo_dir")] ) def test_get_git_file(tmp_dir, erepo): src = "some_file" dst = "some_file_imported" erepo.scm_gen({src: "hello"}, commit="add a regular file") Repo.get(os.fspath(erepo), src, dst) assert (tmp_dir / dst).read_text() == "hello" @pytest.mark.parametrize( "erepo", [pytest.lazy_fixture("git_dir"), pytest.lazy_fixture("erepo_dir")] )
cascade = [node1, node2] return WordSegmenterCascade(cascade) if cuda_is_available: segmenter_fixtures = [ "word_segmenter_gpt2_bert", "word_segmenter_unigram", "word_segmenter_unigram_bert", "word_segmenter_unigram_gpt2", "word_segmenter_unigram_gpt2_bert_cascade" ] else: segmenter_fixtures = ["word_segmenter_unigram"] segmenter_fixtures = [pytest.lazy_fixture(x) for x in segmenter_fixtures] @pytest.mark.parametrize('word_segmenter', segmenter_fixtures) def test_word_segmenter_output_format(word_segmenter): test_boun_hashtags = ["minecraf", "ourmomentfragrance", "waybackwhen"] predictions = word_segmenter.predict(test_boun_hashtags).output predictions_chars = [x.replace(" ", "") for x in predictions] assert predictions_chars[0] == "minecraf" assert predictions_chars[1] == "ourmomentfragrance" assert predictions_chars[2] == "waybackwhen"
def test_score_complex_data(data_random_complex): x = data_random_complex model = Koopman().fit(x) with pytest.raises(ValueError): model.score(x, cast_as_real=False) @pytest.mark.parametrize( "observables", [ Identity(), Polynomial(), TimeDelay(), pytest.lazy_fixture("data_custom_observables"), ], ) def test_observables_integration(data_random, observables): x = data_random model = Koopman(observables=observables).fit(x) check_is_fitted(model) y = model.predict(x) assert y.shape[1] == x.shape[1] @pytest.mark.parametrize( "observables", [ Identity(),
from hypothesis.strategies import builds from hypothesis.strategies import integers from cartesian.cgp import * from cartesian.cgp import _boilerplate from cartesian.cgp import _get_valid_inputs def make_ind(random_state=None, **kwargs): return Cartesian(**kwargs).create(random_state=random_state) ind_strat = builds( make_ind, name=s.just("Individual"), primitive_set=s.just(pytest.lazy_fixture("pset")), n_columns=integers(min_value=1, max_value=10), n_rows=integers(min_value=1, max_value=10), n_back=integers(min_value=1, max_value=10), n_out=integers(min_value=1, max_value=5), ) def test_PrimitiveSet(pset): assert pset.mapping == { 1: pset.terminals[0], 2: pset.terminals[1], 0: pset.terminals[2], 3: pset.operators[0], } assert pset.max_arity == 1
model.fit(x, t, x_dot=x.flatten()) check_is_fitted(model) def test_nan_derivatives(data_lorenz): x, t = data_lorenz model = SINDy(differentiation_method=FiniteDifference(drop_endpoints=True)) model.fit(x, t) check_is_fitted(model) @pytest.mark.parametrize( "data", [ pytest.lazy_fixture("data_1d"), pytest.lazy_fixture("data_lorenz"), pytest.lazy_fixture("data_1d_bad_shape"), ], ) def test_mixed_inputs(data): x, t = data # Scalar t model = SINDy() model.fit(x, t=2) check_is_fitted(model) # x_dot is passed in model = SINDy() model.fit(x, x_dot=x)
py_val = numpy.squeeze(py_data[py_key][:, :4]) else: py_val = numpy.squeeze(py_data[py_key]) assert_close(py_val, ml_val, atol=atol, rtol=rtol) def _compare_6d(py_data, ml_data, fields, atol=1.e-12, rtol=1.e-7): for (ml_key, py_key) in fields: ml_val = _py_data(ml_data[ml_key]) py_val = numpy.squeeze(py_data[py_key]) assert_close(py_val, ml_val, atol=atol, rtol=rtol) @pytest.mark.parametrize('dp', (-0.01, 0.0, 0.01)) @pytest.mark.parametrize( 'lattices', [pytest.lazy_fixture('hmba'), pytest.lazy_fixture('dba')]) def test_4d_analysis(engine, lattices, dp): """Compare linopt6 in 4D""" py_lattice, ml_lattice, _ = lattices fields = [ ('SPos', 's_pos'), ('ClosedOrbit', 'closed_orbit'), ('M', 'M'), ('A', 'A'), ('Dispersion', 'dispersion'), ('alpha', 'alpha'), ('beta', 'beta'), ('mu', 'mu'), ] pypts = range(10)
def data_derivative_1d(): x = 2 * np.linspace(1, 100, 100) x_dot = 2 * np.ones(100).reshape(-1, 1) return x, x_dot @pytest.fixture def data_derivative_2d(): x = np.zeros((100, 2)) x = x.at[:, 0].set(2 * np.linspace(1, 100, 100)) x = x.at[:, 1].set(-10 * np.linspace(1, 100, 100)) x_dot = np.ones((100, 2)) x_dot = x_dot.at[:, 0].mul(2) x_dot = x_dot.at[:, 1].mul(-10) return x, x_dot @pytest.mark.parametrize( "data, order", [ (pytest.lazy_fixture("data_derivative_1d"), 1), (pytest.lazy_fixture("data_derivative_2d"), 1), ], ) def test_finite_difference(data, order): x, x_dot = data diff = finite_difference(order=order) t = np.array([1]) onp.testing.assert_allclose(diff(x, t), x_dot)
# migrate, check logging migration = Migration(dynamo_client, dynamo_table) with caplog.at_level(logging.WARNING): migration.run() assert len(caplog.records) == 0 # verify final state for key, item in zip(keys, items): assert dynamo_table.get_item(Key=key)['Item'] == item @pytest.mark.parametrize( 'item, expected_messages_count', [ [pytest.lazy_fixture('zero_message_count'), 0], [pytest.lazy_fixture('nonzero_message_count'), 7], [pytest.lazy_fixture('both_counts'), 15], ], ) def test_migrate_one(dynamo_client, dynamo_table, caplog, item, expected_messages_count): # verify starting state key = {k: item[k] for k in ('partitionKey', 'sortKey')} assert dynamo_table.get_item(Key=key)['Item'] == item # migrate, check logging migration = Migration(dynamo_client, dynamo_table) with caplog.at_level(logging.WARNING): migration.run() assert len(caplog.records) == 1
'filter': {}, 'fields': ['document_id', 'field'], 'limit': 10, 'sort': [{ 'document_id': SortOrder.DESC.value }] } expected = tuple( {field: document_record[field] for field in ['document_id', 'field']} for document_record in test_documents_records[::-1]) return (find_criteria, expected) @pytest.fixture(params=[ pytest.lazy_fixture('no_filter_all'), pytest.lazy_fixture('filter_greater_than_result'), pytest.lazy_fixture('filter_limit_result'), pytest.lazy_fixture('filter_greater_than_orded_by_result'), pytest.lazy_fixture('filter_orded_by_result'), pytest.lazy_fixture('filter_orded_by_desc_result'), ]) def find_criteria_result(request): return request.param @pytest.fixture def xml_test(): return """ <?xml version = "1.0" encoding = "UTF-8"?> <!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN" "JATS-journalpublishing1.dtd" >
from dvc.cache import NamedCache from dvc.external_repo import clean_repos from dvc.main import main from dvc.remote.base import ( STATUS_DELETED, STATUS_MISSING, STATUS_NEW, STATUS_OK, ) from dvc.stage.exceptions import StageNotFound from dvc.tree.local import LocalTree from dvc.utils.fs import move, remove from dvc.utils.serialize import dump_yaml, load_yaml all_clouds = [ pytest.lazy_fixture(cloud) for cloud in [ "s3", "gs", "azure", "gdrive", "ssh", "http", "hdfs", "webdav", "webhdfs", ] ] + [ pytest.param( pytest.lazy_fixture("oss"), marks=pytest.mark.xfail( reason="https://github.com/iterative/dvc/issues/4633", ),
scm_tree = scm.get_tree("HEAD", use_dvcignore=True) path = os.fspath(tmp_dir) get_dirs = itemgetter(1) assert get_dirs(next(dvc_tree.walk(path))) == [] assert get_dirs(next(scm_tree.walk(path))) == [] kw = {"ignore_subrepos": False} assert get_dirs(next(dvc_tree.walk(path, **kw))) == ["subdir"] assert get_dirs(next(scm_tree.walk(path, **kw))) == ["subdir"] @pytest.mark.parametrize( "cloud", [ pytest.lazy_fixture("local_cloud"), pytest.lazy_fixture("s3"), pytest.lazy_fixture("gs"), pytest.lazy_fixture("hdfs"), pytest.lazy_fixture("http"), ], ) def test_tree_getsize(dvc, cloud): cloud.gen({"data": {"foo": "foo"}, "baz": "baz baz"}) tree = get_cloud_tree(dvc, **cloud.config) path_info = tree.path_info assert tree.getsize(path_info / "baz") == 7 assert tree.getsize(path_info / "data" / "foo") == 3
import pytest from hippiepug.pack import encode, decode from hippiepug.pack import EncodingParams @pytest.mark.parametrize('obj', [ pytest.lazy_fixture('node'), pytest.lazy_fixture('leaf'), pytest.lazy_fixture('block'), b'binary string' ]) def test_msgpack_serialization(obj): """Check serialization correctness.""" a = obj serialized = encode(a) b = decode(serialized) assert a == b def test_custom_defaults(): def mock_encoder(obj): return b'encoded!' def mock_decoder(obj): return b'decoded!' mock_params = EncodingParams() mock_params.encoder = mock_encoder mock_params.decoder = mock_decoder with mock_params.as_default():
client_kwargs=dict(endpoint_url='http://{}:{}'.format(host, port))) fs = PyFileSystem(FSSpecHandler(fs)) fs.create_dir(bucket) yield dict( fs=fs, pathfn=bucket.__add__, allow_copy_file=True, allow_move_dir=False, allow_append_to_file=True, ) fs.delete_dir(bucket) @pytest.fixture(params=[ pytest.param(pytest.lazy_fixture('localfs'), id='LocalFileSystem()'), pytest.param(pytest.lazy_fixture('localfs_with_mmap'), id='LocalFileSystem(use_mmap=True)'), pytest.param(pytest.lazy_fixture('subtree_localfs'), id='SubTreeFileSystem(LocalFileSystem())'), pytest.param(pytest.lazy_fixture('s3fs'), id='S3FileSystem'), pytest.param(pytest.lazy_fixture('hdfs'), id='HadoopFileSystem'), pytest.param(pytest.lazy_fixture('mockfs'), id='_MockFileSystem()'), pytest.param(pytest.lazy_fixture('py_localfs'), id='PyFileSystem(ProxyHandler(LocalFileSystem()))'), pytest.param(pytest.lazy_fixture('py_mockfs'), id='PyFileSystem(ProxyHandler(_MockFileSystem()))'), pytest.param(pytest.lazy_fixture('py_fsspec_localfs'), id='PyFileSystem(FSSpecHandler(fsspec.LocalFileSystem()))'), pytest.param( pytest.lazy_fixture('py_fsspec_memoryfs'),
import numpy as np import pytest import xarray as xr from esmtools.temporal import to_annual @pytest.mark.parametrize( 'dataset', ( pytest.lazy_fixture('gridded_da_datetime'), pytest.lazy_fixture('gridded_da_cftime'), ), ) def test_to_annual(dataset): """General checks that `to_annual` time conversion is working as expected.""" data = dataset() result = to_annual(data) assert result.notnull().all() assert 'year' in result.dims def test_to_annual_accuracy(ts_monthly_da): """Tests that weighted sum correctly takes the annual mean.""" data = ts_monthly_da().isel(time=slice(0, 12)) MONTH_LENGTHS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] manual_sum = [] for i in range(len(data)): manual_sum.append(data[i].values * MONTH_LENGTHS[i] / 365) expected = sum(manual_sum) actual = to_annual(data)
from dvc.utils.fs import remove from tests.unit.fs.test_repo import make_subrepo cloud_names = [ "s3", "gs", "azure", "gdrive", "oss", "ssh", "http", "hdfs", "webdav", "webhdfs", ] clouds = [pytest.lazy_fixture(cloud) for cloud in cloud_names] all_clouds = [pytest.lazy_fixture("local_cloud")] + clouds # `lazy_fixture` is confusing pylint, pylint: disable=unused-argument @pytest.mark.parametrize("remote", clouds, indirect=True) def test_get_url(tmp_dir, dvc, remote): tmp_dir.dvc_gen("foo", "foo") expected_url = URLInfo(remote.url) / "ac/bd18db4cc2f85cedef654fccc4a4d8" assert api.get_url("foo") == expected_url @pytest.mark.parametrize("cloud", clouds) def test_get_url_external(tmp_dir, erepo_dir, cloud):
from dvc.api import UrlNotDvcRepoError from dvc.exceptions import FileMissingError from dvc.path_info import URLInfo from dvc.utils.fs import remove cloud_names = [ "s3", "gs", "azure", "gdrive", "oss", "ssh", "hdfs", "http", ] clouds = [pytest.lazy_fixture(cloud) for cloud in cloud_names] all_clouds = [pytest.lazy_fixture("local")] + clouds remotes = [pytest.lazy_fixture(f"{cloud}_remote") for cloud in cloud_names] all_remotes = [pytest.lazy_fixture("local_remote")] + remotes # `lazy_fixture` is confusing pylint, pylint: disable=unused-argument @pytest.mark.parametrize("remote", remotes) def test_get_url(tmp_dir, dvc, remote): tmp_dir.dvc_gen("foo", "foo") expected_url = URLInfo(remote.url) / "ac/bd18db4cc2f85cedef654fccc4a4d8" assert api.get_url("foo") == expected_url
): await generate_models(specification) with caplog.at_level(DEBUG): assert await pull() == expected_result assert f"Pulled {len(elements)} events from Mobilizon." in caplog.text assert expected_result == await get_all_events() assert ( f"There are now {len(expected_result)} unpublished events." in caplog.text ) assert expected_result == await events_without_publications() @pytest.mark.asyncio @pytest.mark.parametrize( "publisher_class", [pytest.lazy_fixture("mock_publisher_class")] ) @pytest.mark.parametrize( "elements, specification, expected_pull, expected_publish", [ [ [second_event_element(), first_event_element()], empty_specification, [event_0, event_1], event_0, ], ], ) async def test_pull_start( generate_models, mock_mobilizon_success_answer,
# To test a single translator use the -k parameter followed by either # timescale or crate. # See https://docs.pytest.org/en/stable/example/parametrize.html from conftest import crate_translator, timescale_translator from utils.common import TIME_INDEX_NAME from utils.tests.common import create_random_entities, add_attr import datetime from utils.tests.common import create_random_entities import pytest translators = [ pytest.lazy_fixture('crate_translator'), pytest.lazy_fixture('timescale_translator') ] @pytest.mark.parametrize("translator", translators, ids=["crate", "timescale"]) def test_aggr_per_second(translator): entities = create_random_entities(num_ids_per_type=2, num_updates=17) assert len(entities) == 34 # One update every 100 millis -> 10 updates per second. base_index = datetime.datetime(2010, 1, 1, 8, 0, 0, 0, datetime.timezone.utc) delta = datetime.timedelta(milliseconds=100) for i, e in enumerate(entities): t = base_index + i * delta e[TIME_INDEX_NAME] = t.isoformat(timespec='milliseconds')
response = client_admin.get( reverse('zoneeditor:zone_record_edit', kwargs={'zone': 'example.com.'})) assert response.status_code == 405 @pytest.mark.django_db() def test_recordeditview_get_unauthenicated(client): url = reverse('zoneeditor:zone_record_edit', kwargs={'zone': 'example.com.'}) response = client.post(url) TestCase().assertRedirects(response, f'/accounts/login/?next={url}') @pytest.mark.parametrize('client', [ (pytest.lazy_fixture('client_admin')), (pytest.lazy_fixture('client_user_tenant_admin')), ]) @pytest.mark.django_db() def test_recordeditview_post_granted(client, mock_create_record, mock_delete_record, signed_record_data): response = client.post(reverse('zoneeditor:zone_record_edit', kwargs={'zone': 'example.com.'}), data={'identifier': signed_record_data}) assert response.status_code == 200 form = response.context_data['form'] assert form['identifier'].value() == signed_record_data assert form['name'].value() == 'mail.example.com.' assert form['rtype'].value() == 'MX' assert form['ttl'].value() == 300 assert form['content'].value() == '0 example.org.'
FourierLibrary(include_sin=False, include_cos=False) with pytest.raises(ValueError): library_functions = [lambda x: x, lambda x: x**2, lambda x: 0 * x] function_names = [lambda s: str(s), lambda s: "{}^2".format(s)] CustomLibrary(library_functions=library_functions, function_names=function_names) @pytest.mark.parametrize( "library", [ IdentityLibrary(), PolynomialLibrary(), FourierLibrary(), IdentityLibrary() + PolynomialLibrary(), pytest.lazy_fixture("data_custom_library"), ], ) def test_fit_transform(data_lorenz, library): x, t = data_lorenz library.fit_transform(x) check_is_fitted(library) @pytest.mark.parametrize( "library", [ IdentityLibrary(), PolynomialLibrary(), FourierLibrary(), IdentityLibrary() + PolynomialLibrary(),
dvc.imp_url(os.fspath(erepo_dir / "non-existent")) def test_import_url_with_no_exec(tmp_dir, dvc, erepo_dir): tmp_dir.gen({"data_dir": {"file": "file content"}}) src = os.path.join("data_dir", "file") dvc.imp_url(src, ".", no_exec=True) dst = tmp_dir / "file" assert not dst.exists() @pytest.mark.parametrize( "workspace", [ pytest.lazy_fixture("local_cloud"), pytest.lazy_fixture("s3"), pytest.lazy_fixture("azure"), pytest.param( pytest.lazy_fixture("gs"), marks=pytest.mark.needs_internet ), pytest.lazy_fixture("hdfs"), pytest.lazy_fixture("webhdfs"), pytest.param( pytest.lazy_fixture("ssh"), marks=pytest.mark.skipif( os.name == "nt", reason="disabled on windows" ), ), pytest.lazy_fixture("http"), ],
def post_mention_card_template(user, post): yield templates.PostMentionCardTemplate(user.id, post=post) @pytest.fixture def post_views_card_template(user, post): yield templates.PostViewsCardTemplate(user.id, post.id) post1 = post post2 = post @pytest.mark.parametrize( 'template', pytest.lazy_fixture(['chat_card_template', 'comment_card_template', 'requested_followers_card_template']), ) def test_add_or_update_card(user, template, card_manager): # verify starting state assert card_manager.get_card(template.card_id) is None # add the card, verify state before = pendulum.now('utc') card_manager.add_or_update_card(template) after = pendulum.now('utc') card = card_manager.get_card(template.card_id) assert card.id == template.card_id assert card.item['title'] == template.title assert card.item['action'] == template.action assert before < card.created_at < after if template.notify_user_after:
except IOError: # BucketAlreadyOwnedByYou on second test pass return dict( fs=fs, pathfn=bucket.__add__, allow_copy_file=True, allow_move_dir=False, allow_append_to_file=True, ) @pytest.fixture(params=[ pytest.param( pytest.lazy_fixture('localfs'), id='LocalFileSystem()' ), pytest.param( pytest.lazy_fixture('localfs_with_mmap'), id='LocalFileSystem(use_mmap=True)' ), pytest.param( pytest.lazy_fixture('subtree_localfs'), id='SubTreeFileSystem(LocalFileSystem())' ), pytest.param( pytest.lazy_fixture('s3fs'), id='S3FileSystem' ), pytest.param(
import pytest from exercises.models import Exercise, Set, Workload @pytest.fixture(autouse=True) def reset_workload_sequence(workload_factory, workload_template_factory): workload_factory.reset_sequence(0) workload_template_factory.reset_sequence(0) yield @pytest.mark.parametrize( 'factory, num_workloads, idx', [(pytest.lazy_fixture('exercise_factory'), 2, 1), (pytest.lazy_fixture('exercise_template_factory'), 2, 1)], ids=['exercise', 'exercise_template']) @pytest.mark.django_db def test_exercise_delitem(factory, num_workloads, idx): exercise = factory(workloads=num_workloads) del exercise[idx] workloads = exercise.workloads.all() assert workloads.count() == num_workloads - 1 assert [workload.order for workload in workloads] == list(range(num_workloads - 1)) @pytest.mark.parametrize( 'factory, num_workloads, idx1, idx2',
for stage in stages: assert stage is not None assert len(stage.deps) == 0 assert len(stage.outs) == 1 assert stage.relpath in expected_rel_paths # Current dir should not be taken into account assert stage.wdir == os.path.dirname(stage.path) assert stage.outs[0].def_path in expected_def_paths @pytest.mark.parametrize( "workspace, hash_name, hash_value", [ ( pytest.lazy_fixture("local_cloud"), "md5", "8c7dd922ad47494fc02c388e12c00eac", ), pytest.param( pytest.lazy_fixture("ssh"), "md5", "8c7dd922ad47494fc02c388e12c00eac", marks=pytest.mark.skipif(os.name == "nt", reason="disabled on windows"), ), ( pytest.lazy_fixture("s3"), "etag", "8c7dd922ad47494fc02c388e12c00eac", ),
assert stage is not None assert len(stage.deps) == 0 assert len(stage.outs) == 1 assert stage.relpath == subdir_path + ".dvc" # Current dir should not be taken into account assert stage.wdir == os.path.dirname(stage.path) assert stage.outs[0].def_path == "subdata" @pytest.mark.parametrize( "workspace, hash_name, hash_value", [ ( pytest.lazy_fixture("local_cloud"), "md5", "8c7dd922ad47494fc02c388e12c00eac", ), pytest.param( pytest.lazy_fixture("ssh"), "md5", "8c7dd922ad47494fc02c388e12c00eac", marks=pytest.mark.skipif(os.name == "nt", reason="disabled on windows"), ), ( pytest.lazy_fixture("s3"), "etag", "8c7dd922ad47494fc02c388e12c00eac", ),