-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix hashing and repr strings for sql format params
- Loading branch information
1 parent
bc7f1e3
commit 654c97c
Showing
4 changed files
with
91 additions
and
5 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
from __future__ import annotations |
File renamed without changes.
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,32 @@ | ||
import ry | ||
|
||
params_list: list[tuple[str, int | str | float]] = [ | ||
("zoom_level", "0"), | ||
("tile_column", 0), | ||
("tile_row", "0"), | ||
] | ||
|
||
params_arr = [ | ||
params_list, | ||
[("zoom_level", "0"), ("tile_column", "0"), ("tile_row", "0")], | ||
{"zoom_level": "0", "tile_column": "0", "tile_row": "0"}, | ||
{"zoom_level": 0, "tile_column": 0, "tile_row": 0}, | ||
] | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize("params", params_arr) | ||
def test_sqlparams(params): | ||
sqlfmt_params_obj = ry.sqlfmt_params( | ||
params, | ||
) | ||
|
||
# test the repr | ||
repr_str = "ry." + repr(sqlfmt_params_obj) | ||
print(repr_str) | ||
# exec | ||
round_tripped = eval(repr_str) | ||
print("ry." + repr(round_tripped)) | ||
assert sqlfmt_params_obj == round_tripped | ||
assert hash(sqlfmt_params_obj) == hash(round_tripped) |