-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backend-agnostic testing #1205
Backend-agnostic testing #1205
Changes from all commits
bbee536
7cc469a
efdba92
95d5d94
ab82a41
36ff118
d410a72
6205ecf
82aad68
5a969df
46743d5
9d1b616
0084235
06d8689
fcac00e
31d9a6e
c88fd2a
2a6f83f
a5ad43a
a5a8c6d
d519d79
429c2b5
b60ab8b
86bcd7f
c54d592
9421825
4689889
479abf0
47dee8d
712a53c
185d1d8
ceba5d7
b75cef4
22f546a
d33debf
e13c766
5ad108b
9fd04a2
5285bb2
2bdc7f6
db07e3b
e5cd592
c2cf894
e51320c
93cb31d
8f644db
918f109
ee6376a
6e7e536
713a372
9188be3
9bb8d2d
92e2234
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
* | ||
|
||
!tests/ | ||
!splink/ | ||
!pyproject.toml | ||
!poetry.lock | ||
!README.md | ||
|
||
**/*.pyc |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,4 +172,7 @@ cython_debug/ | |
*.parquet | ||
*.csv | ||
|
||
.DS_Store | ||
.DS_Store | ||
|
||
# vscode local settings | ||
.vscode |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# add default marker to all tests - this flag is on by default | ||
# set in pyproject.toml to aid testing tests/ | ||
def pytest_collection_modifyitems(items, config): | ||
for item in items: | ||
item.add_marker("default") |
This file was deleted.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,4 +61,21 @@ select = [ | |
ignore = [ | ||
"B905", # `zip()` without an explicit `strict=` parameter | ||
"B006", # Do not use mutable data structures for argument defaults" | ||
] | ||
] | ||
|
||
[tool.pytest.ini_options] | ||
addopts = ["-m default"] | ||
markers = [ | ||
# only tests where backend is irrelevant: | ||
"core", | ||
# see tests/decorator.py::dialect_groups for group details: | ||
"default", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've taken benchmarking to be a separate workstream and consider them running separately, as they are performing different functions. As far as this PR goes I have just included the changes so that benchmarking runs the same as previously. |
||
"all", | ||
# backend-specific sets | ||
"duckdb", | ||
"duckdb_only", | ||
Comment on lines
+75
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ignore me, you have a note about this in your main description. |
||
"spark", | ||
"spark_only", | ||
"sqlite", | ||
"sqlite_only", | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import pytest | ||
|
||
dialect_groups = { | ||
"duckdb": ["default"], | ||
"spark": ["default"], | ||
"sqlite": [], | ||
} | ||
for groups in dialect_groups.values(): | ||
groups.append("all") | ||
|
||
|
||
def invert(sql_dialects_missing): | ||
return ( | ||
sql_d for sql_d in dialect_groups.keys() if sql_d not in sql_dialects_missing | ||
) | ||
|
||
|
||
def mark_with_dialects_excluding(*sql_dialects_missing): | ||
sql_dialects = invert(sql_dialects_missing) | ||
return mark_with_dialects_including(*sql_dialects, pass_dialect=True) | ||
|
||
|
||
def mark_with_dialects_including(*sql_dialects, pass_dialect=False): | ||
def mark_decorator(test_fn): | ||
params = [] | ||
all_marks = [] | ||
for sql_d in sql_dialects: | ||
# marks for whatever groups the dialect is in | ||
marks = [ | ||
getattr(pytest.mark, dialect_group) | ||
for dialect_group in dialect_groups[sql_d] | ||
] | ||
# plus the basic dialect mark | ||
dialect_mark = getattr(pytest.mark, sql_d) | ||
dialect_only_mark = getattr(pytest.mark, f"{sql_d}_only") | ||
marks += [dialect_mark, dialect_only_mark] | ||
params.append(pytest.param(sql_d, marks=marks)) | ||
# will end up with duplicates, but think that's okay. for now at least. | ||
all_marks += marks | ||
|
||
if pass_dialect: | ||
test_fn = pytest.mark.parametrize("dialect", params)(test_fn) | ||
else: | ||
for mark in all_marks: | ||
test_fn = mark(test_fn) | ||
return test_fn | ||
|
||
return mark_decorator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
core
isn't currently running any tests for meThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, is this running without a folder specified? think in that case it is picking up
conftest.py
frombenchmarking/
which doesn't include the same logic.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as in are you doing just e.g.
pytest -m core
rather thanpytest -m core tests/
?If so would you expect that to run the tests and benchmarking? If so I can either copy the functionality to benchmarking, or even perhaps lift
conftest
to root level so that it covers both