Repository navigation
bpo-40331: Increase test coverage for the statistics module #19608
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
Changes from 1 commit
ccd8bef
21084c1
49def61
b2b9844
50a843f
bbe16bd
74b047a
1a5c2df
ac8b586
ee55b16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1004,7 +1004,7 @@ def test_nan(self): | |
| x = statistics._convert(nan, type(nan)) | ||
| self.assertTrue(_nan_equal(x, nan)) | ||
|
|
||
| def test_raise_type_error(self): | ||
| def test_invalid_input_type(self): | ||
| with self.assertRaises(TypeError): | ||
| statistics._convert(None, float) | ||
|
|
||
|
|
@@ -1040,11 +1040,11 @@ def test_error_msg(self): | |
| class FindLteqTest(unittest.TestCase): | ||
| # Test _find_lteq private function. | ||
|
|
||
| def test_raise_value_error(self): | ||
| def test_invalid_input_values(self): | ||
| for a, x in [ | ||
| ([], 1), # empty a triggers `i != len(a)` | ||
| ([1, 2], 3), # non-existing max value triggers `i != len(a)` | ||
| ([1, 3], 2) # non-existing value triggers `a[i] == x` | ||
| ([], 1), | ||
| ([1, 2], 3), | ||
| ([1, 3], 2) | ||
| ]: | ||
| with self.assertRaises(ValueError): | ||
| statistics._find_lteq(a, x) | ||
|
|
@@ -1063,8 +1063,8 @@ class FindRteqTest(unittest.TestCase): | |
|
|
||
| def test_raise_value_error(self): | ||
| for a, l, x in [ | ||
| ([1], 2, 1), # when l=len(a)+1 triggers `i != (len(a)+1)` | ||
| ([1, 3], 0, 2) # non-existing value triggers `a[i-1] == x` | ||
| ([1], 2, 1), | ||
| ([1, 3], 0, 2) | ||
| ]: | ||
| with self.assertRaises(ValueError): | ||
| statistics._find_rteq(a, l, x) | ||
|
|
@@ -1522,7 +1522,7 @@ def test_negative_error(self): | |
| self.assertRaises(exc, self.func, values) | ||
|
|
||
| def test_single_value_unsupported_type(self): | ||
| with self.assertRaisesRegex(TypeError, '^unsupported type$'): | ||
| with self.assertRaises(TypeError): | ||
| self.func(['3.14']) | ||
|
|
||
| def test_multiple_values_type_error(self): | ||
|
Contributor
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. This could be combined with the previous test method.
Contributor
Author
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. Indeed, now they assert the same behavior, with the same way. I will combine them under a test with name |
||
|
|
||
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 think this test method could also be renamed, similarly to the previous ones.
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.
Sorry, I should have changed this too.