- Notifications
You must be signed in to change notification settings - Fork 434
Add issubset, issuperset and size to Range type #563
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits Select commit Hold shift + click to select a range
cc46f14 Add issubset, issuperset and size to Range type
kdorsel 7096db1 Separate out lower and upper subset checks
kdorsel 534dce4 Remove size method
kdorsel 44960d3 Add Range type tests
kdorsel 9cb36ac Replace f-strings for python 3.5 support
kdorsel ae69caa flake8 fixes
kdorsel 797d8fb Merge branch 'master' into range-methods
elprans 07480c4 Update tests/test_types.py
elprans File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,55 @@ | ||
| # Copyright (C) 2016-present the ayncpg authors and contributors | ||
| # <see AUTHORS file> | ||
| # | ||
| # This module is part of asyncpg and is released under | ||
| # the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0 | ||
| | ||
| from itertools import product | ||
| | ||
| from asyncpg.types import Range | ||
| from asyncpg import _testbase as tb | ||
| | ||
| class TestTypes(tb.TestCase): | ||
| | ||
| def test_range_issubset(self): | ||
| subs = [ | ||
| Range(empty=True), | ||
| Range(lower=1, upper=5, lower_inc=True, upper_inc=False), | ||
| Range(lower=1, upper=5, lower_inc=True, upper_inc=True), | ||
| Range(lower=1, upper=5, lower_inc=False, upper_inc=True), | ||
| Range(lower=1, upper=5, lower_inc=False, upper_inc=False), | ||
| Range(lower=-5, upper=10), | ||
| Range(lower=2, upper=3), | ||
| Range(lower=1, upper=None), | ||
| Range(lower=None, upper=None) | ||
| ] | ||
| | ||
| sups = [ | ||
| Range(empty=True), | ||
| Range(lower=1, upper=5, lower_inc=True, upper_inc=False), | ||
| Range(lower=1, upper=5, lower_inc=True, upper_inc=True), | ||
| Range(lower=1, upper=5, lower_inc=False, upper_inc=True), | ||
| Range(lower=1, upper=5, lower_inc=False, upper_inc=False), | ||
| Range(lower=None, upper=None) | ||
| ] | ||
| | ||
| # Each row is 1 subs with all sups | ||
| results = [ | ||
| True, True, True, True, True, True, | ||
| False, True, True, False, False, True, | ||
| False, False, True, False, False, True, | ||
| False, False, True, True, False, True, | ||
| False, True, True, True, True, True, | ||
| False, False, False, False, False, True, | ||
| False, True, True, True, True, True, | ||
| False, False, False, False, False, True, | ||
| False, False, False, False, False, True | ||
| ] | ||
| | ||
| for (sub, sup), res in zip(product(subs, sups), results): | ||
| self.assertIs( | ||
| sub.issubset(sup), res, "Sub:{}, Sup:{}".format(sub, sup) | ||
| ) | ||
| self.assertIs( | ||
| sup.issuperset(sub), res, "Sub:{}, Sup:{}".format(sub, sup) | ||
| ) | ||
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.