Skip to content

Commit

Permalink
Merge branch 'master' into Mause-patch-5
Browse files Browse the repository at this point in the history
  • Loading branch information
Mause authored Jun 22, 2022
2 parents 59219cb + f87894e commit 09bdd75
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ repos:
- "pytest==6.2.4"
- "hypothesis==6.14.1"
- "sqlalchemy-stubs==0.4"
- "types-setuptools==57.4.17"
- repo: https://github.com/PyCQA/flake8
rev: '4.0.1' # pick a git hash / tag to point to
hooks:
Expand Down
38 changes: 37 additions & 1 deletion duckdb_engine/tests/conftest.py
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)
14 changes: 13 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 09bdd75

Please sign in to comment.