Skip to content

Commit a6b1b8a

Browse files
committed
Add tests for min max functions
1 parent a3e303f commit a6b1b8a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/test_future/test_min_max.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Tests for the min and max functions with `default` keyword.
4+
"""
5+
6+
from __future__ import absolute_import, unicode_literals, print_function
7+
from future.builtins import *
8+
from future.tests.base import unittest
9+
10+
11+
class TestMinMax(unittest.TestCase):
12+
def test_default(self):
13+
self.assertEqual(min([], default=3), 3)
14+
self.assertEqual(max([], default=3), 3)
15+
16+
def test_generator(self):
17+
"""
18+
Issue #510
19+
"""
20+
self.assertEqual(max((x for x in [3, 2, 1])), 3)
21+
self.assertEqual(min((x for x in [1, 2, 3])), 1)
22+
23+
def test_empty_generator(self):
24+
with self.assertRaises(ValueError):
25+
min(x for x in [])

0 commit comments

Comments
 (0)