-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Raw callables only, collected by module lookup.
- Loading branch information
1 parent
2258bd4
commit 6214b74
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
from pathlib import Path | ||
from typing import Any | ||
|
||
|
||
class FixtureManager: | ||
""" | ||
A lean class responsible for resolving parameter values (aka 'fixtures') | ||
of benchmarks from provider functions. | ||
To resolve a benchmark parameter (in resolve()), the class does | ||
the following: | ||
1. Obtain the path to the file containing the benchmark, as | ||
the __file__ attribute of the benchmark function's origin module. | ||
2. Look for a `conf.py` file in the same directory. | ||
3. Import the `conf.py` module, look for a function named the same as | ||
the benchmark parameter. | ||
4. If necessary, resolve any named inputs to the function **within** | ||
the module scope. | ||
5. If no function member is found, and the benchmark file is not in `root`, | ||
fall back to the parent directory, repeat steps 2-5, until `root` is reached. | ||
6. If no `conf.py` contains any function matching the name, throw an | ||
error (TODO: ImportError? custom?) | ||
""" | ||
|
||
def __init__(self, root: str | os.PathLike[str]) -> None: | ||
self.root = Path(root) | ||
self.cache: dict[str, Any] = {} | ||
""" | ||
Cache architecture: | ||
key: directory | ||
value: key-value mapping of fixture name -> fixture value within directory. | ||
""" | ||
|
||
def resolve(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters