Jeremy Hylton | 18da1e1 | 2001-08-20 21:18:56 +0000 | [diff] [blame] | 1 | from __future__ import nested_scopes |
| 2 | from __future__ import division |
Jeremy Hylton | 18da1e1 | 2001-08-20 21:18:56 +0000 | [diff] [blame] | 3 | |
Raymond Hettinger | 158af58 | 2003-07-15 20:57:35 +0000 | [diff] [blame] | 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() |
Jeremy Hylton | 18da1e1 | 2001-08-20 21:18:56 +0000 | [diff] [blame] | 13 | |
| 14 | |
Raymond Hettinger | 158af58 | 2003-07-15 20:57:35 +0000 | [diff] [blame] | 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) |
| 25 | |
| 26 | def test_main(): |
| 27 | test_support.run_unittest(TestFuture) |
| 28 | |
| 29 | if __name__ == "__main__": |
| 30 | test_main() |