Skip to content

Commit 23fe3d0

Browse files
committed
Switch to make_traversable
1 parent 1ffe7ca commit 23fe3d0

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

src/tdom_path/profiling/benchmark.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@
88
import time
99
from pathlib import PurePosixPath
1010

11-
# Add examples to path for Heading component
12-
sys.path.insert(0, "examples")
1311

1412
from tdom import html
1513

16-
from mysite.components.heading import Heading
17-
from tdom_path import make_path, make_path_nodes, render_path_nodes
14+
from tdom_path import make_path_nodes, render_path_nodes, make_traversable
1815
from tdom_path.tree import _walk_tree
1916

2017

@@ -101,9 +98,13 @@ def run_benchmark():
10198

10299
_get_module_files.cache_clear() # Clear cache for cold test
103100

101+
# Add examples to path for Heading component
102+
sys.path.insert(0, "examples")
103+
from mysite.components.heading import Heading
104+
104105
results["make_path_cold"] = benchmark_operation(
105106
"make_path() - relative (COLD cache)",
106-
lambda: make_path(Heading, "static/styles.css"),
107+
lambda: make_traversable(Heading, "static/styles.css"),
107108
iterations=100,
108109
warmup=False, # No warmup for cold cache test
109110
)
@@ -112,12 +113,12 @@ def run_benchmark():
112113
print("\n [Warm cache tests - simulating repeated use...]")
113114
results["make_path"] = benchmark_operation(
114115
"make_path() - relative (WARM cache)",
115-
lambda: make_path(Heading, "static/styles.css"),
116+
lambda: make_traversable(Heading, "static/styles.css"),
116117
)
117118

118119
results["make_path_pkg"] = benchmark_operation(
119120
"make_path() - package path (WARM)",
120-
lambda: make_path(None, "tests.fixtures.fake_package:static/styles.css"),
121+
lambda: make_traversable(None, "tests.fixtures.fake_package:static/styles.css"),
121122
)
122123

123124
# SSG Simulation: Transform same tree for multiple pages

tests/test_tree.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,9 @@ def test_validate_asset_exists_with_missing_asset():
12261226
import pytest
12271227

12281228
# Test with non-existent asset from fake_package
1229-
asset_path = make_traversable(None, "tests.fixtures.fake_package:static/nonexistent.css")
1229+
asset_path = make_traversable(
1230+
None, "tests.fixtures.fake_package:static/nonexistent.css"
1231+
)
12301232
component = Heading
12311233
attr_name = "href"
12321234

@@ -1335,7 +1337,9 @@ def test_validate_asset_exists_error_includes_path_string():
13351337
import pytest
13361338

13371339
# Test with missing asset
1338-
asset_path = make_traversable(None, "tests.fixtures.fake_package:static/notfound.css")
1340+
asset_path = make_traversable(
1341+
None, "tests.fixtures.fake_package:static/notfound.css"
1342+
)
13391343

13401344
# Should include path information in error
13411345
with pytest.raises(FileNotFoundError) as exc_info:

0 commit comments

Comments
 (0)