Best Python code snippet using localstack_python
spec.py
Source:spec.py  
...128    Creates a new ServiceCatalogIndex and stores it into the given file_path.129    :param file_path: the path to pickle to130    :return: the created ServiceCatalogIndex131    """132    return save_service_index_cache(LazyServiceCatalogIndex(), file_path)133def load_service_index_cache(file: str) -> ServiceCatalogIndex:134    """135    Loads from the given file the pickled ServiceCatalogIndex.136    :param file: the file to load from137    :return: the loaded ServiceCatalogIndex138    """139    import pickle140    with open(file, "rb") as fd:141        return pickle.load(fd)142def save_service_index_cache(index: LazyServiceCatalogIndex, file_path: str) -> ServiceCatalogIndex:143    """144    Creates from the given LazyServiceCatalogIndex a ``ServiceCatalogIndex`, pickles its contents into the given file,145    and then returns the newly created index.146    :param index: the LazyServiceCatalogIndex to store the index from.147    :param file_path: the path to pickle to148    :return: the created ServiceCatalogIndex149    """150    import pickle151    cache = ServiceCatalogIndex(152        service_names=index.service_names,153        endpoint_prefix_index=index.endpoint_prefix_index,154        operations_index=index.operations_index,155        signing_name_index=index.signing_name_index,156        target_prefix_index=index.target_prefix_index,...test_spec.py
Source:test_spec.py  
...7)8def test_pickled_index_equals_lazy_index(tmp_path):9    file_path = tmp_path / "index-cache.pickle"10    lazy_index = LazyServiceCatalogIndex()11    save_service_index_cache(lazy_index, str(file_path))12    cached_index = load_service_index_cache(str(file_path))13    assert cached_index.service_names == lazy_index.service_names14    assert cached_index.target_prefix_index == lazy_index.target_prefix_index15    assert cached_index.signing_name_index == lazy_index.signing_name_index16    assert cached_index.operations_index == lazy_index.operations_index17    assert cached_index.endpoint_prefix_index == lazy_index.endpoint_prefix_index18def test_patching_loaders():19    # first test that specs remain intact20    loader = PatchingLoader({})21    description = loader.load_service_model("s3", "service-2")22    model = ServiceModel(description, "s3")23    shape = model.shape_for("NoSuchBucket")24    # by default, the s3 error shapes have no members, but AWS will actually return additional attributes25    assert not shape.members...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
