~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Lib/test/test_builtin.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Python test set -- built-in functions
2
2
 
 
3
import platform
3
4
import test.test_support, unittest
4
5
from test.test_support import fcmp, have_unicode, TESTFN, unlink, \
5
6
                              run_unittest, run_with_locale
13
14
 
14
15
# count the number of test runs.
15
16
# used to skip running test_execfile() multiple times
 
17
# and to create unique strings to intern in test_intern()
16
18
numruns = 0
17
19
 
18
20
class Squares:
646
648
 
647
649
    def test_intern(self):
648
650
        self.assertRaises(TypeError, intern)
649
 
        s = "never interned before"
 
651
        # This fails if the test is run twice with a constant string,
 
652
        # therefore append the run counter
 
653
        s = "never interned before " + str(numruns)
650
654
        self.assert_(intern(s) is s)
651
655
        s2 = s.swapcase().swapcase()
652
656
        self.assert_(intern(s2) is s)
1256
1260
        self.assertRaises(TypeError, round, t)
1257
1261
        self.assertRaises(TypeError, round, t, 0)
1258
1262
 
 
1263
    def test_round_large(self):
 
1264
        # Issue #1869: integral floats should remain unchanged
 
1265
        self.assertEqual(round(5e15-1), 5e15-1)
 
1266
        self.assertEqual(round(5e15), 5e15)
 
1267
        self.assertEqual(round(5e15+1), 5e15+1)
 
1268
        self.assertEqual(round(5e15+2), 5e15+2)
 
1269
        self.assertEqual(round(5e15+3), 5e15+3)
 
1270
 
1259
1271
    def test_setattr(self):
1260
1272
        setattr(sys, 'spam', 1)
1261
1273
        self.assertEqual(sys.spam, 1)