Skip to content
Prev Previous commit
Next Next commit
Rename tests and remove comments as requested in review
  • Loading branch information
tzabal committed Apr 26, 2020
commit 1a5c2dff0c98ca23ca3b16ea45e28c6c0fbcd0da
16 changes: 8 additions & 8 deletions Lib/test/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand All @@ -1063,8 +1063,8 @@ class FindRteqTest(unittest.TestCase):

def test_raise_value_error(self):

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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.

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)
Expand Down Expand Up @@ -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):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be combined with the previous test method.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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 test_invalid_type_error.

Expand Down