from cloudpathlib.local import LocalS3Path, LocalS3Client
path = LocalS3Path("s3://some/path/")
path.touch()
LocalS3Client.reset_default_storage_dir()
new_path = LocalS3Path("s3://some/path/")
assert not new_path.is_file() # fails
The reason is that reset_default_storage_dir() acts on the class attribute only and not on the instance attribute of the LocalClient in question. Because of Client.get_default_client() returning the same client instance for any path (saved as a class attribute), no new client gets instantiated to make use of the new directory. The tests don’t catch that because they create the clients explicitly.
The reason is that
reset_default_storage_dir()acts on the class attribute only and not on the instance attribute of theLocalClientin question. Because ofClient.get_default_client()returning the same client instance for any path (saved as a class attribute), no new client gets instantiated to make use of the new directory. The tests don’t catch that because they create the clients explicitly.