Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 158af58

Browse files
committed
Fixed test and converted to unittest format.
Checking // would call floor division but did not test that true division had become the default with 'from __future__ import division'.
1 parent e37b4ed commit 158af58

1 file changed

Lines changed: 25 additions & 6 deletions

File tree

Lib/test/test_future3.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
11
from __future__ import nested_scopes
22
from __future__ import division
3-
from __future__ import nested_scopes
43

5-
def f(x):
6-
def g(y):
7-
return y // x
8-
return g
4+
import unittest
5+
from test import test_support
6+
7+
x = 2
8+
def nester():
9+
x = 3
10+
def inner():
11+
return x
12+
return inner()
13+
14+
15+
class TestFuture(unittest.TestCase):
16+
17+
def test_floor_div_operator(self):
18+
self.assertEqual(7 // 2, 3)
19+
20+
def test_true_div_as_default(self):
21+
self.assertAlmostEqual(7 / 2, 3.5)
22+
23+
def test_nested_scopes(self):
24+
self.assertEqual(nester(), 3)
925

26+
def test_main():
27+
test_support.run_unittest(TestFuture)
1028

11-
print f(2)(5)
29+
if __name__ == "__main__":
30+
test_main()

0 commit comments

Comments
 (0)