-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into Mause-patch-5
- Loading branch information
Showing
3 changed files
with
51 additions
and
2 deletions.
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
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 |
---|---|---|
@@ -1,11 +1,47 @@ | ||
from pytest import fixture | ||
from typing import Any, Callable, TypeVar | ||
|
||
import duckdb | ||
from packaging.specifiers import SpecifierSet | ||
from pytest import fixture, mark | ||
from sqlalchemy import create_engine | ||
from sqlalchemy.dialects import registry | ||
from sqlalchemy.engine import Engine | ||
from typing_extensions import Protocol | ||
|
||
FuncT = TypeVar("FuncT", bound=Callable[..., Any]) | ||
|
||
|
||
@fixture | ||
def engine() -> Engine: | ||
registry.register("duckdb", "duckdb_engine", "Dialect") # type: ignore | ||
|
||
return create_engine("duckdb:///:memory:") | ||
|
||
|
||
class HasVersion(Protocol): | ||
__version__: str | ||
|
||
|
||
def library_version( | ||
library: HasVersion, | ||
specifiers: str, | ||
) -> Callable[[FuncT], FuncT]: | ||
""" | ||
Specify which versions of a library a test should run against | ||
""" | ||
|
||
def decorator(func: FuncT) -> FuncT: | ||
return mark.xfail( | ||
not has_version, | ||
reason=f"{library} version not desired - desired {specifiers}, found {installed}", | ||
)(func) | ||
|
||
installed = library.__version__ | ||
has_version = SpecifierSet(specifiers).contains(installed, prereleases=True) | ||
|
||
return decorator | ||
|
||
|
||
def duckdb_version(specifiers: str) -> Callable[[FuncT], FuncT]: | ||
"Specify which versions of duckdb a test should run against" | ||
return library_version(duckdb, specifiers) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.