annotate Lib/test/test_future3.py @ 58925:eecf1bef052d 2.6

Merged revisions 78207 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line #7930: fix stripid ........
author Ezio Melotti <ezio.melotti@gmail.com>
date Tue, 16 Feb 2010 23:29:44 +0000
parents 1a42b128c581
children 9c930a32cebb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19409
bc9c8cebc2ef Add test case to cover multiple future statements on separate lines of
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1 from __future__ import nested_scopes
bc9c8cebc2ef Add test case to cover multiple future statements on separate lines of
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2 from __future__ import division
29872
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
3
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
4 import unittest
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
5 from test import test_support
19409
bc9c8cebc2ef Add test case to cover multiple future statements on separate lines of
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
6
29872
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
7 x = 2
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
8 def nester():
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
9 x = 3
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
10 def inner():
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
11 return x
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
12 return inner()
19409
bc9c8cebc2ef Add test case to cover multiple future statements on separate lines of
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
13
bc9c8cebc2ef Add test case to cover multiple future statements on separate lines of
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
14
29872
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
15 class TestFuture(unittest.TestCase):
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
16
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
17 def test_floor_div_operator(self):
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
18 self.assertEqual(7 // 2, 3)
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
19
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
20 def test_true_div_as_default(self):
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
21 self.assertAlmostEqual(7 / 2, 3.5)
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
22
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
23 def test_nested_scopes(self):
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
24 self.assertEqual(nester(), 3)
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
25
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
26 def test_main():
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
27 test_support.run_unittest(TestFuture)
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
28
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
29 if __name__ == "__main__":
1a42b128c581 Fixed test and converted to unittest format.
Raymond Hettinger <python@rcn.com>
parents: 19409
diff changeset
30 test_main()