Skip to content

Commit 2e4fed3

Browse files
committed
test: coverage
1 parent a4b8f83 commit 2e4fed3

4 files changed

Lines changed: 40 additions & 39 deletions

File tree

src/inline_snapshot/_external/_storage.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ def load(self, location: ExternalLocation) -> Generator[Path]:
7272

7373
@property
7474
def _external_files(self):
75-
if not hasattr(self, "_external_files_cache"):
76-
from inline_snapshot._global_state import state
75+
from inline_snapshot._global_state import state
76+
77+
if not hasattr(state(), "_external_files_cache"):
7778

78-
self._external_files_cache = {}
79+
state()._external_files_cache = {}
7980

8081
base_folders = {file.parent for file in state().files_with_snapshots}
8182

@@ -85,8 +86,8 @@ def _external_files(self):
8586

8687
for folder in base_folders:
8788
for file in folder.rglob("????????-????-????-????-????????????.*"):
88-
self._external_files_cache[file.name] = file
89-
return self._external_files_cache
89+
state()._external_files_cache[file.name] = file
90+
return state()._external_files_cache
9091

9192
def _lookup_path(self, location: ExternalLocation):
9293
if location.filename and location.qualname:
@@ -248,12 +249,6 @@ def _lookup_path(self, name) -> Path:
248249
def lookup_all(self, name: str) -> set[str]:
249250
return {file.name for file in self.directory.glob(name)}
250251

251-
def lookup_all_path(self, name: str) -> set[Path]:
252-
return {file for file in self.directory.glob(name)}
253-
254-
def remove(self, name):
255-
self._lookup_path(name).unlink()
256-
257252

258253
def default_storages(storage_dir: Path):
259254
return {"hash": HashStorage(storage_dir / "external"), "uuid": UuidStorage()}

tests/external/test_external.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,6 @@ def test_basic(check_update):
2626
# )
2727

2828

29-
def test_max_hash():
30-
Example(
31-
{
32-
"test_something.py": """\
33-
from inline_snapshot import external
34-
def test_a():
35-
assert "a" == external()
36-
""",
37-
"pyproject.toml": """\
38-
[tool.inline-snapshot]
39-
hash-length=64
40-
""",
41-
}
42-
).run_inline(
43-
["--inline-snapshot=create"],
44-
changed_files=snapshot(
45-
{
46-
"__inline_snapshot__/test_something/test_a/e3e70682-c209-4cac-a29f-6fbed82c07cd.txt": "a",
47-
"test_something.py": """\
48-
from inline_snapshot import external
49-
def test_a():
50-
assert "a" == external("uuid:e3e70682-c209-4cac-a29f-6fbed82c07cd.txt")
51-
""",
52-
}
53-
),
54-
)
55-
56-
5729
def test_outsource():
5830

5931
Example(

tests/external/test_generic.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ def test_generic(storage):
1313
def test_a():
1414
assert "testa".upper()==external("{storage}:")
1515
"""
16+
).run_pytest(
17+
["--inline-snapshot=report"],
18+
returncode=snapshot(1),
1619
).run_inline(
1720
["--inline-snapshot=create"],
1821
changed_files=snapshot(
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from inline_snapshot._inline_snapshot import snapshot
2+
from inline_snapshot.testing._example import Example
3+
4+
5+
def test_max_hash():
6+
Example(
7+
{
8+
"test_something.py": """\
9+
from inline_snapshot import external
10+
def test_a():
11+
assert "a" == external()
12+
""",
13+
"pyproject.toml": """\
14+
[tool.inline-snapshot]
15+
hash-length=64
16+
default-storage="hash"
17+
""",
18+
}
19+
).run_inline(
20+
["--inline-snapshot=create"],
21+
changed_files=snapshot(
22+
{
23+
".inline-snapshot/external/ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb.txt": "a",
24+
"test_something.py": """\
25+
from inline_snapshot import external
26+
def test_a():
27+
assert "a" == external("hash:ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb.txt")
28+
""",
29+
}
30+
),
31+
)

0 commit comments

Comments
 (0)