Skip to content

Commit c1a3b1f

Browse files
authored
tests: fix interaction between azure tests (#123)
* tests: fix interaction between azure tests * update changelog entry
1 parent 38dd3c0 commit c1a3b1f

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Changed
1010
- updated past changelog entries.
1111

12+
### Fixed
13+
- improved azure test separation (#123).
14+
1215
## [0.0.24] - 2023-06-19
1316
### Added
1417
- started a changelog to keep track of significant changes (#118).

upath/tests/conftest.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import sys
66
import threading
77
import time
8+
import uuid
89
from pathlib import Path
910

1011
import fsspec
@@ -32,7 +33,6 @@ def clear_registry():
3233

3334
@pytest.fixture(scope="function")
3435
def local_testdir(tmp_path, clear_registry):
35-
tmp_path.mkdir(exist_ok=True)
3636
folder1 = tmp_path.joinpath("folder1")
3737
folder1.mkdir()
3838
folder1_files = ["file1.txt", "file2.txt"]
@@ -367,13 +367,31 @@ def docker_azurite(azurite_credentials):
367367

368368

369369
@pytest.fixture(scope="session")
370-
def azure_fixture(azurite_credentials, docker_azurite):
370+
def azure_container(azurite_credentials, docker_azurite):
371371
azure_storage = pytest.importorskip("azure.storage.blob")
372372
account_name, connection_string = azurite_credentials
373373
client = azure_storage.BlobServiceClient.from_connection_string(
374374
conn_str=connection_string
375375
)
376-
container_name = "data"
376+
container_name = str(uuid.uuid4())
377377
client.create_container(container_name)
378378

379-
yield f"az://{container_name}"
379+
try:
380+
yield container_name
381+
finally:
382+
client.delete_container(container_name)
383+
384+
385+
@pytest.fixture(scope="function")
386+
def azure_fixture(azurite_credentials, azure_container):
387+
azure_storage = pytest.importorskip("azure.storage.blob")
388+
account_name, connection_string = azurite_credentials
389+
client = azure_storage.BlobServiceClient.from_connection_string(
390+
conn_str=connection_string
391+
).get_container_client(azure_container)
392+
393+
try:
394+
yield f"az://{azure_container}"
395+
finally:
396+
for blob in client.list_blobs():
397+
client.delete_blob(blob["name"])

upath/tests/implementations/test_azure.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def test_rmdir(self):
3232
path = new_dir / "test.txt"
3333
path.write_text("hello")
3434
assert path.exists()
35-
new_dir.fs.invalidate_cache()
3635
new_dir.rmdir()
3736
assert not new_dir.exists()
3837

@@ -43,6 +42,5 @@ def test_rmdir(self):
4342
def test_makedirs_exist_ok_false(self):
4443
pass
4544

46-
@pytest.mark.xfail(reason="test interaction")
4745
def test_rglob(self, pathlib_base):
4846
return super().test_rglob(pathlib_base)

0 commit comments

Comments
 (0)