-
Notifications
You must be signed in to change notification settings - Fork 17
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
Interval exception detect when modify the lower or the upper property on an exist interval instance #48
base: master
Are you sure you want to change the base?
Interval exception detect when modify the lower or the upper property on an exist interval instance #48
Changes from 9 commits
c620de3
351f8b6
47df2a3
f0fd97b
a85b471
1fe9602
a5531a4
98db8a1
d87d03d
8b82b08
cbd4917
dfe2f4b
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 |
---|---|---|
|
@@ -20,18 +20,18 @@ def test_string_as_constructor_param(self): | |
with raises(TypeError) as e: | ||
FloatInterval('(0.2, 0.5)') | ||
assert ( | ||
'First argument should be a list or tuple. If you wish to ' | ||
'initialize an interval from string, use from_string factory ' | ||
'method.' | ||
) in str(e) | ||
'First argument should be a list or tuple. If you wish to ' | ||
'initialize an interval from string, use from_string factory ' | ||
'method.' | ||
) in str(e) | ||
|
||
def test_invalid_argument(self): | ||
with raises(IllegalArgument) as e: | ||
FloatInterval((0, 0)) | ||
assert ( | ||
'The bounds may be equal only if at least one of the bounds is ' | ||
'closed.' | ||
) in str(e) | ||
'The bounds may be equal only if at least one of the bounds is ' | ||
'closed.' | ||
) in str(e) | ||
|
||
def test_floats(self): | ||
interval = FloatInterval((0.2, 0.5)) | ||
|
@@ -155,11 +155,11 @@ def test_empty_string_as_lower_bound_for_char_interval(self): | |
@mark.parametrize( | ||
('number_range', 'lower', 'upper'), | ||
( | ||
('-2-2', -2, 2), | ||
('-3--2', -3, -2), | ||
('2-3', 2, 3), | ||
('2-', 2, inf), | ||
('-5', -5, -5) | ||
('-2-2', -2, 2), | ||
('-3--2', -3, -2), | ||
('2-3', 2, 3), | ||
('2-', 2, inf), | ||
('-5', -5, -5) | ||
) | ||
) | ||
def test_hyphen_format(self, number_range, lower, upper): | ||
|
@@ -170,18 +170,18 @@ def test_hyphen_format(self, number_range, lower, upper): | |
@mark.parametrize( | ||
('constructor', 'number_range'), | ||
( | ||
(IntInterval, (3, 2)), | ||
(IntInterval, [4, 2]), | ||
(IntInterval, (float('inf'), 2)), | ||
(CharacterInterval, ('c', 'b')), | ||
(CharacterInterval, ('d', 'b')), | ||
(CharacterInterval, (inf, 'b')), | ||
(IntInterval, (3, 2)), | ||
(IntInterval, [4, 2]), | ||
(IntInterval, (float('inf'), 2)), | ||
(CharacterInterval, ('c', 'b')), | ||
(CharacterInterval, ('d', 'b')), | ||
(CharacterInterval, (inf, 'b')), | ||
) | ||
) | ||
def test_raises_exception_for_badly_constructed_range( | ||
self, | ||
constructor, | ||
number_range | ||
self, | ||
constructor, | ||
number_range | ||
): | ||
with raises(RangeBoundsException): | ||
constructor(number_range) | ||
|
@@ -191,14 +191,58 @@ class TestTypeGuessing(object): | |
@mark.parametrize( | ||
('number_range', 'type'), | ||
( | ||
((2, 3), int), | ||
([-6, 8], int), | ||
(8.5, float), | ||
([Decimal(2), 9], int), | ||
([Decimal('0.5'), 9], float), | ||
([date(2000, 1, 1), inf], date), | ||
(('a', 'e'), str), | ||
((2, 3), int), | ||
([-6, 8], int), | ||
(8.5, float), | ||
([Decimal(2), 9], int), | ||
([Decimal('0.5'), 9], float), | ||
([date(2000, 1, 1), inf], date), | ||
(('a', 'e'), str), | ||
) | ||
) | ||
def test_guesses_types(self, number_range, type): | ||
assert Interval(number_range).type == type | ||
|
||
|
||
class TestIntervalChanging(object): | ||
@mark.parametrize( | ||
('constructor', 'number_range', 'bad_lower'), | ||
( | ||
(IntInterval, (1, 2), 3), | ||
(IntInterval, [1, 2], 3), | ||
(IntInterval, (1, 2), float('inf')), | ||
(CharacterInterval, ('a', 'b'), 'c'), | ||
(CharacterInterval, ('a', 'b'), 'd'), | ||
(CharacterInterval, ('a', 'b'), inf), | ||
) | ||
) | ||
def test_raises_exception_for_badly_lower_changing( | ||
self, | ||
constructor, | ||
number_range, | ||
bad_lower | ||
): | ||
with raises(RangeBoundsException): | ||
interval = constructor(number_range) | ||
interval.lower = bad_lower | ||
|
||
@mark.parametrize( | ||
('constructor', 'number_range', 'bad_upper'), | ||
( | ||
(IntInterval, (1, 2), 0), | ||
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. Use the indentation of 4 spaces not 8. 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. The indentation has been revised to 4. 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. There are still lines with indentation of 8 not 4 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. OK, I will check again and change them. |
||
(IntInterval, [1, 2], 0), | ||
(IntInterval, (1, 2), float('-inf')), | ||
(CharacterInterval, ('b', 'c'), 'a'), | ||
(CharacterInterval, ('b', 'd'), 'a'), | ||
(CharacterInterval, ('b', 'c'), -inf), | ||
) | ||
) | ||
def test_raises_exception_for_badly_upper_changing( | ||
self, | ||
constructor, | ||
number_range, | ||
bad_upper | ||
): | ||
with raises(RangeBoundsException): | ||
interval = constructor(number_range) | ||
interval.upper = bad_upper |
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.
Please remove this and all similar style changes where you add extra indents.
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.
I have revised all that changes.