-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from kurtmckee/expand-testing
Expand testing
- Loading branch information
Showing
7 changed files
with
117 additions
and
4 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
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
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,24 @@ | ||
import sys | ||
|
||
import sqids | ||
|
||
from hypothesis import given, target, assume | ||
import hypothesis.strategies as st | ||
|
||
|
||
lists_of_integers = st.lists(elements=st.integers(min_value=0, max_value=sys.maxsize)) | ||
min_lengths = st.integers(min_value=1, max_value=100) | ||
alphabets = st.text( | ||
alphabet=st.characters(min_codepoint=0, max_codepoint=0x7f), | ||
min_size=3, | ||
) | ||
|
||
|
||
@given(numbers=lists_of_integers, min_length=min_lengths, alphabet=alphabets) | ||
def test_round_trip_encoding(numbers, min_length, alphabet): | ||
# Encourage hypothesis to find ideal alphabets. | ||
target(len(alphabet) / len(set(alphabet))) | ||
assume(len(alphabet) == len(set(alphabet))) | ||
|
||
sqid = sqids.Sqids(min_length=min_length, alphabet=alphabet, blocklist=[]) | ||
assert sqid.decode(sqid.encode(numbers)) == numbers |
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,40 @@ | ||
[tox] | ||
envlist = | ||
coverage_erase | ||
py{3.13, 3.12, 3.11, 3.10, 3.9, 3.8, 3.7, 3.6} | ||
coverage_report | ||
|
||
skip_missing_interpreters = True | ||
isolated_build = True | ||
|
||
|
||
[testenv] | ||
depends = | ||
py{3.13, 3.12, 3.11, 3.10, 3.9, 3.8, 3.7, 3.6}: coverage_erase | ||
deps = | ||
pytest | ||
hypothesis | ||
coverage[toml] | ||
commands = | ||
coverage run -m pytest | ||
|
||
|
||
[testenv:coverage_erase] | ||
skipsdist = true | ||
skip_install = true | ||
deps = | ||
coverage[toml] | ||
commands = coverage erase | ||
|
||
|
||
[testenv:coverage_report] | ||
depends = | ||
py{3.13, 3.12, 3.11, 3.10, 3.9, 3.8, 3.7, 3.6} | ||
skipsdist = true | ||
skip_install = true | ||
deps = | ||
coverage[toml] | ||
commands_pre = | ||
coverage combine | ||
coverage html --fail-under=0 | ||
commands = coverage report |