Issue 20780: Shadowed (duplicate name but different body) test in test_statistics (original) (raw)

Line 994 of Lib/test/test_statistics.py:

def test_decimal_mismatched_infs_to_nan(self):
    # Test adding Decimal INFs with opposite sign returns NAN.
    inf = Decimal('inf')
    data = [1, 2, inf, 3, -inf, 4]
    with decimal.localcontext(decimal.ExtendedContext):
        self.assertTrue(math.isnan(statistics._sum(data)))

def test_decimal_mismatched_infs_to_nan(self):
    # Test adding Decimal INFs with opposite sign raises InvalidOperation.
    inf = Decimal('inf')
    data = [1, 2, inf, 3, -inf, 4]
    with decimal.localcontext(decimal.BasicContext):
        self.assertRaises(decimal.InvalidOperation, statistics._sum, data)

Here is the patch. I also removed unnecessary import.