Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ This project uses [*towncrier*](https://towncrier.readthedocs.io/) and the chang

<!-- towncrier release notes start -->

## [0.3.1](https://github.com/airspeed-velocity/asv_runner/tree/0.3.1) - 15-08-2026

### Bug Fixes

- Class-level ``setup(self)`` no longer runs inside ``do_setup_cache``.
Bound methods are not treated as parameter-free module hooks, so
``setup_cache`` runs first again
([#52](https://github.com/airspeed-velocity/asv_runner/issues/52)).


## [0.3.0](https://github.com/airspeed-velocity/asv_runner/tree/0.3.0) - 04-08-2026

### Bug Fixes
Expand Down
10 changes: 7 additions & 3 deletions asv_runner/benchmarks/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,11 +646,15 @@ def _build_params(self):
@staticmethod
def _is_parameter_free_setup(setup):
"""
True if ``setup`` can be called with no positional arguments.
True if ``setup`` is a module-level hook callable with no arguments.

Used so module-level ``setup(*args, **kwargs)`` runs before
``setup_cache`` while class ``setup(self, n)`` waits for ``do_setup``.
Module-level ``setup(*args, **kwargs)`` (pandas seed, asv#1592) runs
before ``setup_cache``. Bound class ``setup(self)`` and
``setup(self, n)`` wait for ``do_setup``: ``inspect.signature`` omits
``self`` on bound methods, so ``bind()`` alone would mis-fire.
"""
if inspect.ismethod(setup):
return False
try:
inspect.signature(setup).bind()
except TypeError:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
project = "asv_runner"
copyright = "2023--present, asv Developers"
author = "asv Developers"
release = "0.3.0"
release = "0.3.1"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion tbump.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
github_url = "https://github.com/airspeed-velocity/asv_runner/"

[version]
current = "0.3.0"
current = "0.3.1"

# Example of a semver regexp.
# Make sure this matches current_version before
Expand Down
28 changes: 28 additions & 0 deletions tests/test_cache_skip_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,34 @@ def track_fn(cache, n):
self.assertTrue(Benchmark._is_parameter_free_setup(module_setup))
self.assertFalse(Benchmark._is_parameter_free_setup(class_setup))

def test_bound_class_setup_does_not_run_in_do_setup_cache(self):
# Discovery builds sources as [func, instance, module], so class
# setup(self) is a bound method. signature().bind() then succeeds
# because self is already bound (asv_runner#52).
order = []

class Suite:
def setup(self):
order.append("class_setup")
raise AssertionError("class setup must not run in do_setup_cache")

def setup_cache(self):
order.append("setup_cache")
return {"ok": True}

def track_x(self):
return 1

inst = Suite()
func = inst.track_x
b = TrackBenchmark(
"mod.Suite.track_x", func, [func, inst, sys.modules[__name__]]
)
out = b.do_setup_cache()
self.assertEqual(out, {"ok": True})
self.assertEqual(order, ["setup_cache"])
self.assertFalse(Benchmark._is_parameter_free_setup(inst.setup))

def test_benchmark_decorator_attrs_and_unknown(self):
@benchmark(pretty_name="Pretty", timeout=12.5, max_time=30.0)
def track_fn():
Expand Down
Loading