<86>Sep 14 10:11:38 userdel[3069960]: delete user 'rooter' <86>Sep 14 10:11:38 userdel[3069960]: removed group 'rooter' owned by 'rooter' <86>Sep 14 10:11:38 userdel[3069960]: removed shadow group 'rooter' owned by 'rooter' <86>Sep 14 10:11:38 groupadd[3069965]: group added to /etc/group: name=rooter, GID=693 <86>Sep 14 10:11:38 groupadd[3069965]: group added to /etc/gshadow: name=rooter <86>Sep 14 10:11:38 groupadd[3069965]: new group: name=rooter, GID=693 <86>Sep 14 10:11:38 useradd[3069969]: new user: name=rooter, UID=693, GID=693, home=/root, shell=/bin/bash <86>Sep 14 10:11:38 userdel[3069975]: delete user 'builder' <86>Sep 14 10:11:38 userdel[3069975]: removed group 'builder' owned by 'builder' <86>Sep 14 10:11:38 userdel[3069975]: removed shadow group 'builder' owned by 'builder' <86>Sep 14 10:11:38 groupadd[3069980]: group added to /etc/group: name=builder, GID=694 <86>Sep 14 10:11:38 groupadd[3069980]: group added to /etc/gshadow: name=builder <86>Sep 14 10:11:38 groupadd[3069980]: new group: name=builder, GID=694 <86>Sep 14 10:11:38 useradd[3069985]: new user: name=builder, UID=694, GID=694, home=/usr/src, shell=/bin/bash /usr/src/in/srpm/python3-module-fixedpoint-0.1.2-alt3.src.rpm: license not found in '/usr/share/license' directory: Distributable <13>Sep 14 10:11:40 rpmi: libgdbm-1.8.3-alt10 sisyphus+278100.1600.1.1 1626059138 installed <13>Sep 14 10:11:40 rpmi: libexpat-2.2.10-alt1 sisyphus+276608.100.1.2 1625153360 installed <13>Sep 14 10:11:40 rpmi: libp11-kit-0.23.15-alt2 sisyphus+278382.100.1.2 1626190687 installed <13>Sep 14 10:11:40 rpmi: libtasn1-4.17.0-alt1 sisyphus+276722.100.1.1 1625211286 installed <13>Sep 14 10:11:40 rpmi: rpm-macros-alternatives-0.5.1-alt1 sisyphus+278157.100.2.1 1626055790 installed <13>Sep 14 10:11:40 rpmi: alternatives-0.5.1-alt1 sisyphus+278157.100.2.1 1626055790 installed <13>Sep 14 10:11:40 rpmi: ca-certificates-2021.06.03-alt1 sisyphus+273509.400.1.1 1622736045 installed <13>Sep 14 10:11:40 rpmi: ca-trust-0.1.2-alt1 sisyphus+233348.100.1.1 1561653823 installed <13>Sep 14 10:11:40 rpmi: p11-kit-trust-0.23.15-alt2 sisyphus+278382.100.1.2 1626190687 installed <13>Sep 14 10:11:41 rpmi: libcrypto1.1-1.1.1l-alt1 sisyphus+283685.100.1.1 1629816097 installed <13>Sep 14 10:11:41 rpmi: libssl1.1-1.1.1l-alt1 sisyphus+283685.100.1.1 1629816097 installed <13>Sep 14 10:11:41 rpmi: python3-3.9.6-alt2 sisyphus+283178.100.2.1 1629243244 installed <13>Sep 14 10:11:41 rpmi: python3-base-3.9.6-alt2 sisyphus+283178.100.2.1 1629243244 installed <13>Sep 14 10:11:42 rpmi: libpython3-3.9.6-alt2 sisyphus+283178.100.2.1 1629243244 installed <13>Sep 14 10:11:42 rpmi: tests-for-installed-python3-pkgs-0.1.17-alt1 sisyphus+271082.100.1.1 1619820927 installed <13>Sep 14 10:11:42 rpmi: rpm-build-python3-0.1.17-alt1 sisyphus+271082.100.1.1 1619820927 installed <13>Sep 14 10:11:45 rpmi: libpython-2.7.18-alt7 sisyphus+284067.100.1.1 1630124815 installed <13>Sep 14 10:11:45 rpmi: python2-base-2.7.18-alt7 sisyphus+284067.100.1.1 1630124815 installed <13>Sep 14 10:11:45 rpmi: python-modules-encodings-2.7.18-alt7 sisyphus+284067.100.1.1 1630124815 installed <13>Sep 14 10:11:45 rpmi: python-modules-compiler-2.7.18-alt7 sisyphus+284067.100.1.1 1630124815 installed <13>Sep 14 10:11:46 rpmi: python-modules-email-2.7.18-alt7 sisyphus+284067.100.1.1 1630124815 installed <13>Sep 14 10:11:46 rpmi: python-modules-unittest-2.7.18-alt7 sisyphus+284067.100.1.1 1630124815 installed <13>Sep 14 10:11:46 rpmi: python-modules-2.7.18-alt7 sisyphus+284067.100.1.1 1630124815 installed <13>Sep 14 10:11:46 rpmi: python-modules-ctypes-2.7.18-alt7 sisyphus+284067.100.1.1 1630124815 installed <13>Sep 14 10:11:46 rpmi: python-modules-multiprocessing-2.7.18-alt7 sisyphus+284067.100.1.1 1630124815 installed <13>Sep 14 10:11:46 rpmi: python-modules-logging-2.7.18-alt7 sisyphus+284067.100.1.1 1630124815 installed <13>Sep 14 10:11:46 rpmi: python-tools-2to3-2.7.18-alt7 sisyphus+284067.100.1.1 1630124815 installed Building target platforms: i586 Building for target i586 Wrote: /usr/src/in/nosrpm/python3-module-fixedpoint-0.1.2-alt3.nosrc.rpm (w1.gzdio) Installing python3-module-fixedpoint-0.1.2-alt3.src.rpm Building target platforms: i586 Building for target i586 Executing(%prep): /bin/sh -e /usr/src/tmp/rpm-tmp.84044 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + rm -rf fixedpoint + echo 'Source #0 (fixedpoint.0.1.2.tar.gz):' Source #0 (fixedpoint.0.1.2.tar.gz): + /bin/tar -xf - + /bin/gzip -dc /usr/src/RPM/SOURCES/fixedpoint.0.1.2.tar.gz + cd fixedpoint + /bin/chmod -c -Rf u+rwX,go-w . + find -type f -name '*.py' -exec 2to3 -w -n '{}' + RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ./test_fixedpoint.py --- ./test_fixedpoint.py (original) +++ ./test_fixedpoint.py (refactored) @@ -19,7 +19,7 @@ def __init__(self, value=0, precision=DEFAULT_PRECISION): FixedPoint.__init__(self, value, precision) def __repr__(self): - return "SonOfFixedPoint" + `(str(self), self.p)` + return "SonOfFixedPoint" + repr((str(self), self.p)) class FixedPointTest(unittest.TestCase): """Unit tests for FixedPointy""" @@ -27,175 +27,175 @@ def testCreateDefault(self): """Simply create a default object.""" n = FixedPoint(); - self.assertEquals(n.get_precision(), DEFAULT_PRECISION) - self.assertEquals(long(n), 0) + self.assertEqual(n.get_precision(), DEFAULT_PRECISION) + self.assertEqual(int(n), 0) n = SonOfFixedPoint(); - self.assertEquals(n.get_precision(), DEFAULT_PRECISION) - self.assertEquals(long(n), 0) + self.assertEqual(n.get_precision(), DEFAULT_PRECISION) + self.assertEqual(int(n), 0) def testCreateFromNone(self): """try to slip None in""" - self.failUnlessRaises(TypeError, FixedPoint, None); + self.assertRaises(TypeError, FixedPoint, None); def testCreateFromString(self): """Create a FixedPoint from a string""" # try an empty string - self.failUnlessRaises(ValueError, FixedPoint, ""); + self.assertRaises(ValueError, FixedPoint, ""); # try a fixed point zero n = FixedPoint("0"); - self.assertEquals(n.precision, DEFAULT_PRECISION) - self.assertEquals(n.n, 0L) + self.assertEqual(n.precision, DEFAULT_PRECISION) + self.assertEqual(n.n, 0) # try a floating point zero n = FixedPoint("0.0"); - self.assertEquals(n.precision, DEFAULT_PRECISION) - self.assertEquals(n.n, 0L) + self.assertEqual(n.precision, DEFAULT_PRECISION) + self.assertEqual(n.n, 0) # try a floating point number with a positive exponent n = FixedPoint("42.3e5"); - self.assertEquals(n.precision, DEFAULT_PRECISION) - self.assertEquals(n.n, 423000000L) + self.assertEqual(n.precision, DEFAULT_PRECISION) + self.assertEqual(n.n, 423000000) # try a floating point number with a negative exponent n = FixedPoint("42.3e-1"); - self.assertEquals(n.precision, DEFAULT_PRECISION) - self.assertEquals(n.n, 423L) + self.assertEqual(n.precision, DEFAULT_PRECISION) + self.assertEqual(n.n, 423) # try truncating the precision n = FixedPoint("42.123"); - self.assertEquals(n.precision, DEFAULT_PRECISION) - self.assertEquals(n.n, 4212) + self.assertEqual(n.precision, DEFAULT_PRECISION) + self.assertEqual(n.n, 4212) def testCreateFromIntOrLong(self): """Create a FixedPoint from an int or a long""" # try a negative n = FixedPoint(-333); - self.assertEquals(n.precision, DEFAULT_PRECISION) - self.assertEquals(n.n, -33300) + self.assertEqual(n.precision, DEFAULT_PRECISION) + self.assertEqual(n.n, -33300) # try a zero n = FixedPoint(0); - self.assertEquals(n.precision, DEFAULT_PRECISION) - self.assertEquals(n.n, 0L) + self.assertEqual(n.precision, DEFAULT_PRECISION) + self.assertEqual(n.n, 0) # try a positive n = FixedPoint(333); - self.assertEquals(n.precision, DEFAULT_PRECISION) - self.assertEquals(n.n, 33300L) + self.assertEqual(n.precision, DEFAULT_PRECISION) + self.assertEqual(n.n, 33300) def testCreateFromFixedPoint(self): """Create a FixedPoint from another FixedPoint""" # try a negative n = FixedPoint(-333); - self.assertEquals(n.precision, DEFAULT_PRECISION) - self.assertEquals(n.n, -33300L) + self.assertEqual(n.precision, DEFAULT_PRECISION) + self.assertEqual(n.n, -33300) # try a negative x = FixedPoint(n); - self.assertEquals(x.precision, DEFAULT_PRECISION) - self.assertEquals(x.n, -33300L) + self.assertEqual(x.precision, DEFAULT_PRECISION) + self.assertEqual(x.n, -33300) x = SonOfFixedPoint(n); - self.assertEquals(x.precision, DEFAULT_PRECISION) - self.assertEquals(x.n, -33300L) + self.assertEqual(x.precision, DEFAULT_PRECISION) + self.assertEqual(x.n, -33300) def testCreateFromFloat(self): """Create a FixedPoint from a floating point number""" # try a floating point zero n = FixedPoint(0.0); - self.assertEquals(n.precision, DEFAULT_PRECISION) - self.assertEquals(n.n, 0L) + self.assertEqual(n.precision, DEFAULT_PRECISION) + self.assertEqual(n.n, 0) # try a floating point number with a positive exponent n = FixedPoint(42.3e5); - self.assertEquals(n.precision, DEFAULT_PRECISION) - self.assertEquals(n.n, 423000000L) + self.assertEqual(n.precision, DEFAULT_PRECISION) + self.assertEqual(n.n, 423000000) # try a floating point number with a negative exponent n = FixedPoint(42.3e-1); - self.assertEquals(n.precision, DEFAULT_PRECISION) - self.assertEquals(n.n, 423L) + self.assertEqual(n.precision, DEFAULT_PRECISION) + self.assertEqual(n.n, 423) # try truncating the precision n = FixedPoint(42.123); - self.assertEquals(n.precision, DEFAULT_PRECISION) - self.assertEquals(n.n, 4212L) + self.assertEqual(n.precision, DEFAULT_PRECISION) + self.assertEqual(n.n, 4212) def testCreateFromObject(self): """ Try to create a FixedPoint from something that can't be coerced to a number. """ - self.failUnlessRaises(TypeError, FixedPoint, object); - self.failUnlessRaises(TypeError, SonOfFixedPoint, object); + self.assertRaises(TypeError, FixedPoint, object); + self.assertRaises(TypeError, SonOfFixedPoint, object); def testSetAndGetPrecision(self): """Change and retrieve the precision of an existin object""" # try a floating point number with a negative exponent n = FixedPoint(42.3e-1); - self.assertEquals(n.get_precision(), DEFAULT_PRECISION) - self.assertEquals(n.precision, DEFAULT_PRECISION) - self.assertEquals(n.n, 423L) + self.assertEqual(n.get_precision(), DEFAULT_PRECISION) + self.assertEqual(n.precision, DEFAULT_PRECISION) + self.assertEqual(n.n, 423) n = SonOfFixedPoint(42.3e-1); - self.assertEquals(n.get_precision(), DEFAULT_PRECISION) - self.assertEquals(n.precision, DEFAULT_PRECISION) - self.assertEquals(n.n, 423L) + self.assertEqual(n.get_precision(), DEFAULT_PRECISION) + self.assertEqual(n.precision, DEFAULT_PRECISION) + self.assertEqual(n.n, 423) # try something that's not a number - self.failUnlessRaises(TypeError, n.set_precision, object); - self.failUnlessRaises(TypeError, n.precision, object); + self.assertRaises(TypeError, n.set_precision, object); + self.assertRaises(TypeError, n.precision, object); # try a negative number - self.failUnlessRaises(ValueError, n.set_precision, -3); + self.assertRaises(ValueError, n.set_precision, -3); # try a precision greater than we started with newprecision = DEFAULT_PRECISION + 1 n.set_precision(newprecision) - self.assertEquals(n.get_precision(), newprecision) - self.assertEquals(n.n, 4230L) + self.assertEqual(n.get_precision(), newprecision) + self.assertEqual(n.n, 4230) precision = n.precision + 1 n.precision += 1 - self.assertEquals(n.precision, precision) + self.assertEqual(n.precision, precision) # try a precision less than we started with newprecision = DEFAULT_PRECISION - 1 n.set_precision(newprecision) - self.assertEquals(n.get_precision(), newprecision) - self.assertEquals(n.n, 42) + self.assertEqual(n.get_precision(), newprecision) + self.assertEqual(n.n, 42) def test__str__(self): """test conversion to string""" # try the default n = FixedPoint() - self.assertEquals(str(n), "0.00") + self.assertEqual(str(n), "0.00") n = SonOfFixedPoint() - self.assertEquals(str(n), "0.00") + self.assertEqual(str(n), "0.00") # try a floating point number with a negative exponent n = FixedPoint(42.3e-1); - self.assertEquals(str(n), "4.23") + self.assertEqual(str(n), "4.23") n = SonOfFixedPoint(42.3e-1); - self.assertEquals(str(n), "4.23") + self.assertEqual(str(n), "4.23") # try a negative floating point number n = FixedPoint(-4.23); - self.assertEquals(str(n), "-4.23") + self.assertEqual(str(n), "-4.23") # try an int n = FixedPoint(1, 0); - self.assertEquals(str(n), "1.") + self.assertEqual(str(n), "1.") def test__repr__(self): """test representation""" @@ -204,37 +204,37 @@ # try the default n = FixedPoint() - self.assertEquals(repr(n), REPR_FORMAT % (str(n), n.get_precision())) + self.assertEqual(repr(n), REPR_FORMAT % (str(n), n.get_precision())) # try a floating point number with a negative exponent n = FixedPoint(42.3e-1); - self.assertEquals(repr(n), REPR_FORMAT % (str(n), n.get_precision())) + self.assertEqual(repr(n), REPR_FORMAT % (str(n), n.get_precision())) # try a negative floating point number n = FixedPoint(-4.23); - self.assertEquals(repr(n), REPR_FORMAT % (str(n), n.get_precision())) + self.assertEqual(repr(n), REPR_FORMAT % (str(n), n.get_precision())) # try an int n = FixedPoint(1, 0); - self.assertEquals(repr(n), REPR_FORMAT % (str(n), n.get_precision())) + self.assertEqual(repr(n), REPR_FORMAT % (str(n), n.get_precision())) SON_OF_FORMAT = "SonOfFixedPoint('%s', %d)" # try the default n = SonOfFixedPoint() - self.assertEquals(repr(n), SON_OF_FORMAT % (str(n), n.get_precision())) + self.assertEqual(repr(n), SON_OF_FORMAT % (str(n), n.get_precision())) # try a floating point number with a negative exponent n = SonOfFixedPoint(42.3e-1); - self.assertEquals(repr(n), SON_OF_FORMAT % (str(n), n.get_precision())) + self.assertEqual(repr(n), SON_OF_FORMAT % (str(n), n.get_precision())) # try a negative floating point number n = SonOfFixedPoint(-4.23); - self.assertEquals(repr(n), SON_OF_FORMAT % (str(n), n.get_precision())) + self.assertEqual(repr(n), SON_OF_FORMAT % (str(n), n.get_precision())) # try an int n = SonOfFixedPoint(1, 0); - self.assertEquals(repr(n), SON_OF_FORMAT % (str(n), n.get_precision())) + self.assertEqual(repr(n), SON_OF_FORMAT % (str(n), n.get_precision())) def test__copy__(self): """test shallow copy""" @@ -242,13 +242,13 @@ # try a negative floating point number n = FixedPoint(-4.23); - self.assertEquals(n, copy.copy(n)) - self.failIf(n is copy.copy(n)) + self.assertEqual(n, copy.copy(n)) + self.assertFalse(n is copy.copy(n)) # try a negative floating point number n = SonOfFixedPoint(-4.23); - self.assertEquals(n, copy.copy(n)) - self.failIf(n is copy.copy(n)) + self.assertEqual(n, copy.copy(n)) + self.assertFalse(n is copy.copy(n)) def test__deepcopy__(self): """test deep copy""" @@ -257,14 +257,14 @@ # try a negative floating point number n = FixedPoint(-4.23); - self.assertEquals(n, copy.deepcopy(n)) - self.failIf(n is copy.deepcopy(n)) + self.assertEqual(n, copy.deepcopy(n)) + self.assertFalse(n is copy.deepcopy(n)) # try a negative floating point number n = SonOfFixedPoint(-4.23); - self.assertEquals(n, copy.deepcopy(n)) - self.failIf(n is copy.deepcopy(n)) + self.assertEqual(n, copy.deepcopy(n)) + self.assertFalse(n is copy.deepcopy(n)) def test__cmp__(self): """test compare""" @@ -272,30 +272,30 @@ # test two defaults a = FixedPoint() b = FixedPoint() - self.failIf(a < b) - self.failUnless(a == b) - self.failIf(a > b) + self.assertFalse(a < b) + self.assertTrue(a == b) + self.assertFalse(a > b) # test equal precision a = FixedPoint(1.11) b = FixedPoint(1.12) - self.failUnless(a < b) - self.failIf(a == b) - self.failIf(a > b) + self.assertTrue(a < b) + self.assertFalse(a == b) + self.assertFalse(a > b) # test unequal precision a = FixedPoint(1.125, 3) b = FixedPoint(1.12) - self.failIf(a < b) - self.failIf(a == b) - self.failUnless(a > b) + self.assertFalse(a < b) + self.assertFalse(a == b) + self.assertTrue(a > b) # test equal precision, with subclass a = FixedPoint(1.11) b = SonOfFixedPoint(1.12) - self.failUnless(a < b) - self.failIf(a == b) - self.failIf(a > b) + self.assertTrue(a < b) + self.assertFalse(a == b) + self.assertFalse(a > b) def test__hash__(self): """test the hash function""" @@ -308,30 +308,30 @@ """test the truth value""" # test the default - self.failIf(FixedPoint()) + self.assertFalse(FixedPoint()) # test one that should be true - self.failUnless(FixedPoint(1.0e-15, 15)) + self.assertTrue(FixedPoint(1.0e-15, 15)) def test__neg__(self): """test negative""" # test the default - self.failIf(-FixedPoint()) + self.assertFalse(-FixedPoint()) # test one that should be true - self.failUnless(-FixedPoint(-1.0e-15, 15)) + self.assertTrue(-FixedPoint(-1.0e-15, 15)) def test__abs__(self): """test absolute value""" # test the default d = FixedPoint() - self.assertEquals(abs(d), d) + self.assertEqual(abs(d), d) # test a negative n = FixedPoint(-1.0e-15, 15) - self.assertEquals(abs(n), -n) + self.assertEqual(abs(n), -n) def test__add__(self): """test addition""" @@ -340,58 +340,58 @@ a = FixedPoint(3.33) b = 3.3333 c = a + b - self.assertEquals(type(c), type(a)) - self.assertEquals(c.n, 666) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.n, 666) # test two operands with the same precision a = FixedPoint(3.33) b = FixedPoint(6.66) c = a + b - self.assertEquals(type(c), type(a)) - self.assertEquals(c.n, 999L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.n, 999) # test two operands with differing precision a = FixedPoint(3.33) b = FixedPoint(6.66, 3) c = a + b - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, 9990L) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, 9990) a = FixedPoint(3.33) b = FixedPoint(6.666, 3) c = a + b - self.assertEquals(type(c), type(a)) - self.assertEquals(c.n, 9996L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.n, 9996) # test negatives a = FixedPoint(3.33) b = FixedPoint(-6.66, 3) c = a + b - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, -3330L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, -3330) a = FixedPoint(-3.33) b = FixedPoint(-6.666, 3) c = a + b - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, -9996L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, -9996) # test subclass a = FixedPoint(3.33) b = SonOfFixedPoint(6.666, 3) c = a + b - self.assertEquals(type(c), type(b)) - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, 9996L) + self.assertEqual(type(c), type(b)) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, 9996) a = FixedPoint(3.33) b = SonOfFixedPoint(6.666, 3) c = b + a - self.assertEquals(type(c), type(b)) - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, 9996) + self.assertEqual(type(c), type(b)) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, 9996) def test__radd__(self): """test addition as the right argument""" @@ -400,18 +400,18 @@ a = FixedPoint(3.33) b = 3.3333 c = b + a - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c.n, 666L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c.n, 666) # test subclass a = SonOfFixedPoint(3.33) b = 3.3333 c = b + a - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c.n, 666L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c.n, 666) def test__sub__(self): """test subtraction""" @@ -420,64 +420,64 @@ a = FixedPoint(3.33) b = 3.3333 c = a - b - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c, 0L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c, 0) a = SonOfFixedPoint(3.33) b = 3.3333 c = a - b - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c, 0L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c, 0) # test two operands with the same precision a = FixedPoint(3.33) b = FixedPoint(6.66) c = b - a - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c.n, 333L) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c.n, 333) # test two operands with differing precision a = FixedPoint(3.33) b = FixedPoint(6.66, 3) c = b - a - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, 3330L) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, 3330) a = FixedPoint(3.33) b = FixedPoint(6.666, 3) c = b - a - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, 3336L) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, 3336) # test negatives a = FixedPoint(3.33) b = FixedPoint(-6.66, 3) c = b - a - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, -9990L) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, -9990) a = FixedPoint(-3.33) b = FixedPoint(-6.666, 3) c = b - a - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, -3336L) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, -3336) # test subclass a = FixedPoint(3.33) b = SonOfFixedPoint(6.66, 3) c = a - b - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, -3330L) - self.assertEquals(type(c), type(b)) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, -3330) + self.assertEqual(type(c), type(b)) a = FixedPoint(3.33) b = SonOfFixedPoint(6.66, 3) c = b - a - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, 3330L) - self.assertEquals(type(c), type(b)) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, 3330) + self.assertEqual(type(c), type(b)) def test__rsub__(self): """test subtraction as the right hand argument""" @@ -486,16 +486,16 @@ a = FixedPoint(3.33) b = 1.11 c = b - a - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c.n, -222) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c.n, -222) a = SonOfFixedPoint(3.33) b = 1.11 c = b - a - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c.n, -222) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c.n, -222) def test__mul__(self): @@ -505,62 +505,62 @@ a = FixedPoint(2) b = 3.3333 c = a * b - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c.n, 666L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c.n, 666) # test two operands with the same precision a = FixedPoint(3.33) b = FixedPoint(6.66) c = b * a - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c.n, 2218L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c.n, 2218) # test two operands with differing precision a = FixedPoint(3.33) b = FixedPoint(6.66, 3) c = b * a - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, 22178L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, 22178) # test negatives a = FixedPoint(3.33) b = FixedPoint(-6.66, 3) c = b * a - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, -22178L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, -22178) a = FixedPoint(-3.33) b = FixedPoint(-6.666, 3) c = b * a - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, 22198L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, 22198) # test subclass a = FixedPoint(3.33) b = SonOfFixedPoint(6.66, 3) c = a * b - self.assertEquals(type(c), type(b)) - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, 22178L) + self.assertEqual(type(c), type(b)) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, 22178) a = FixedPoint(3.33) b = SonOfFixedPoint(6.66, 3) c = b * a - self.assertEquals(type(c), type(b)) - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, 22178L) + self.assertEqual(type(c), type(b)) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, 22178) a = FixedPoint(3.33) b = 3 c = a * b - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c.n, 999) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c.n, 999) def test__rmul__(self): """test multiplication""" @@ -568,16 +568,16 @@ a = FixedPoint(3.33) b = 3 c = b * a - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c.n, 999L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c.n, 999) a = SonOfFixedPoint(3.33) b = 3 c = b * a - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c.n, 999L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c.n, 999) def test__div__(self): @@ -587,69 +587,69 @@ a = FixedPoint(6.66) b = 3.3333 c = a / b - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c.n, 200L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c.n, 200) a = SonOfFixedPoint(6.66) b = 3.3333 c = a / b - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c.n, 200L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c.n, 200) # test two operands with the same precision a = FixedPoint(3.33) b = FixedPoint(6.66) c = b / a - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c.n, 200L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c.n, 200) # test two operands with differing precision a = FixedPoint(1) b = FixedPoint(3, 3) c = b / a - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, 3000L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, 3000) # test negatives a = FixedPoint(3.33) b = FixedPoint(-6.66, 3) c = b / a - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, -2000L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, -2000) a = FixedPoint(-3.33) b = FixedPoint(-6.66) c = b / a - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c.n, 200L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c.n, 200) # test subclass a = FixedPoint(3.33) b = SonOfFixedPoint(6.66, 3) c = a / b - self.assertEquals(type(c), type(b)) - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, 500) + self.assertEqual(type(c), type(b)) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, 500) a = FixedPoint(3.33) b = SonOfFixedPoint(6.66, 3) c = b / a - self.assertEquals(type(c), type(b)) - self.assertEquals(c.precision, 3) - self.assertEquals(c.n, 2000L) + self.assertEqual(type(c), type(b)) + self.assertEqual(c.precision, 3) + self.assertEqual(c.n, 2000) a = FixedPoint(3.33) b = 3 c = a / b - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c.n, 111L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c.n, 111) def test__rdiv__(self): """test right division""" @@ -657,40 +657,40 @@ a = FixedPoint(3) b = 1 c = b / a - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, DEFAULT_PRECISION) - self.assertEquals(c.n, 33L) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, DEFAULT_PRECISION) + self.assertEqual(c.n, 33) a = SonOfFixedPoint(3.33, 6) b = 1 c = b / a - self.assertEquals(type(c), type(a)) - self.assertEquals(c.precision, 6) - self.assertEquals(c.n, 300300) + self.assertEqual(type(c), type(a)) + self.assertEqual(c.precision, 6) + self.assertEqual(c.n, 300300) def test__divmod__(self): """test integer division with modulo""" a = FixedPoint(3.33) q, m = divmod(a, 2) - self.assertEquals(type(q), type(1L)) - self.assertEquals(type(m), type(a)) - self.assertEquals(q, 1) - self.assertEquals(m, FixedPoint(1.33)) + self.assertEqual(type(q), type(1)) + self.assertEqual(type(m), type(a)) + self.assertEqual(q, 1) + self.assertEqual(m, FixedPoint(1.33)) a = SonOfFixedPoint(3.33) q, m = divmod(a, 2) - self.assertEquals(type(q), type(1L)) - self.assertEquals(type(m), type(a)) - self.assertEquals(q, 1L) - self.assertEquals(m, FixedPoint(1.33)) + self.assertEqual(type(q), type(1)) + self.assertEqual(type(m), type(a)) + self.assertEqual(q, 1) + self.assertEqual(m, FixedPoint(1.33)) a = FixedPoint(3.33) b = FixedPoint(1.11) q, m = divmod(a, b) - self.assertEquals(type(q), type(1L)) - self.assertEquals(type(m), type(a)) - self.assertEquals(q, 3L) - self.assertEquals(m, FixedPoint(0)) + self.assertEqual(type(q), type(1)) + self.assertEqual(type(m), type(a)) + self.assertEqual(q, 3) + self.assertEqual(m, FixedPoint(0)) # 2002-10-19 dougfort -- this produces infinite recursion ## a = FixedPoint(3.33) @@ -705,53 +705,53 @@ """test right integer division with modulo""" a = FixedPoint(3.33) q, m = divmod(4, a) - self.assertEquals(q, 1L) - self.assertEquals(m, FixedPoint(0.67)) + self.assertEqual(q, 1) + self.assertEqual(m, FixedPoint(0.67)) def test__mod__(self): """test modulo""" a = FixedPoint(3.33) b = 2 c = a % b - self.assertEquals(c, FixedPoint(1.33)) + self.assertEqual(c, FixedPoint(1.33)) a = FixedPoint(3.33) b = FixedPoint(1.111) c = a % b - self.assertEquals(c, FixedPoint(0)) + self.assertEqual(c, FixedPoint(0)) def test__rmod__(self): """test right modulo""" a = FixedPoint(3.33) b = 4 c = b % a - self.assertEquals(c, FixedPoint(0.67)) + self.assertEqual(c, FixedPoint(0.67)) a = FixedPoint(3.33) b = SonOfFixedPoint(6.666) c = b % a - self.assertEquals(c, SonOfFixedPoint(0.01)) + self.assertEqual(c, SonOfFixedPoint(0.01)) def test__float__(self): """test casting to float""" - self.assertEquals(float(4), float(FixedPoint(4))) - self.assertEquals(3.1416, float(FixedPoint(3.14159, 4))) + self.assertEqual(float(4), float(FixedPoint(4))) + self.assertEqual(3.1416, float(FixedPoint(3.14159, 4))) def test__long__(self): """test casting to long""" - self.assertEquals(4, long(FixedPoint(4))) - self.assertEquals(3, long(FixedPoint(3.14159, 4))) + self.assertEqual(4, int(FixedPoint(4))) + self.assertEqual(3, int(FixedPoint(3.14159, 4))) def test__int__(self): """test casting to int""" - self.assertEquals(4, int(FixedPoint(4))) - self.assertEquals(3, int(FixedPoint(3.14159, 4))) + self.assertEqual(4, int(FixedPoint(4))) + self.assertEqual(3, int(FixedPoint(3.14159, 4))) def testFrac(self): """test return of the fractional portion""" - self.assertEquals( + self.assertEqual( FixedPoint(), FixedPoint(4).frac()) - self.assertEquals( + self.assertEqual( FixedPoint(0.1416, 4), FixedPoint(3.14159, 4).frac()) @@ -760,10 +760,10 @@ prevrounding = FixedPoint.round FixedPoint.round = bankersRounding # we expect to round 1 up because it's odd - self.assertEquals( + self.assertEqual( FixedPoint(1.5,0), FixedPoint(2.0,0)) # we expect to leave 2 alone because it's even - self.assertEquals( + self.assertEqual( FixedPoint(2.5,0), FixedPoint(2.0,0)) FixedPoint.round = prevrounding @@ -772,10 +772,10 @@ prevrounding = FixedPoint.round FixedPoint.round = addHalfAndChop # we expect to round 1 up - self.assertEquals( + self.assertEqual( FixedPoint(1.5,0), FixedPoint(2.0,0)) # we expect to round 2 up as well - self.assertEquals( + self.assertEqual( FixedPoint(2.5,0), FixedPoint(3.0,0)) FixedPoint.round = prevrounding @@ -783,58 +783,58 @@ """Tim's oringinal tests in __main__ of fixedpoint.py""" fp = FixedPoint o = fp("0.1") - self.assert_(str(o) == "0.10") + self.assertTrue(str(o) == "0.10") t = fp("-20e-2", 5) - self.assert_(str(t) == "-0.20000") - self.assert_(t < o) - self.assert_(o > t) - self.assert_(min(o, t) == min(t, o) == t) - self.assert_(max(o, t) == max(t, o) == o) - self.assert_(o != t) - self.assert_(--t == t) - self.assert_(abs(t) > abs(o)) - self.assert_(abs(o) < abs(t)) - self.assert_(o == o and t == t) - self.assert_(t.copy() == t) - self.assert_(o == -t/2 == -.5 * t) - self.assert_(abs(t) == o + o) - self.assert_(abs(o) == o) - self.assert_(o/t == -0.5) - self.assert_(-(t/o) == (-t)/o == t/-o == 2) - self.assert_(1 + o == o + 1 == fp(" +00.000011e+5 ")) - self.assert_(1/o == 10) - self.assert_(o + t == t + o == -o) - self.assert_(2.0 * t == t * 2 == "2" * t == o/o * 2L * t) - self.assert_(1 - t == -(t - 1) == fp(6L)/5) - self.assert_(t*t == 4*o*o == o*4*o == o*o*4) - self.assert_(fp(2) - "1" == 1) - self.assert_(float(-1/t) == 5.0) + self.assertTrue(str(t) == "-0.20000") + self.assertTrue(t < o) + self.assertTrue(o > t) + self.assertTrue(min(o, t) == min(t, o) == t) + self.assertTrue(max(o, t) == max(t, o) == o) + self.assertTrue(o != t) + self.assertTrue(--t == t) + self.assertTrue(abs(t) > abs(o)) + self.assertTrue(abs(o) < abs(t)) + self.assertTrue(o == o and t == t) + self.assertTrue(t.copy() == t) + self.assertTrue(o == -t/2 == -.5 * t) + self.assertTrue(abs(t) == o + o) + self.assertTrue(abs(o) == o) + self.assertTrue(o/t == -0.5) + self.assertTrue(-(t/o) == (-t)/o == t/-o == 2) + self.assertTrue(1 + o == o + 1 == fp(" +00.000011e+5 ")) + self.assertTrue(1/o == 10) + self.assertTrue(o + t == t + o == -o) + self.assertTrue(2.0 * t == t * 2 == "2" * t == o/o * 2 * t) + self.assertTrue(1 - t == -(t - 1) == fp(6)/5) + self.assertTrue(t*t == 4*o*o == o*4*o == o*o*4) + self.asseRefactoringTool: Refactored ./fixedpoint.py rtTrue(fp(2) - "1" == 1) + self.assertTrue(float(-1/t) == 5.0) for p in range(20): - self.assert_(42 + fp("1e-20", p) - 42 == 0) - self.assert_(1/(42 + fp("1e-20", 20) - 42) == fp("100.0E18")) + self.assertTrue(42 + fp("1e-20", p) - 42 == 0) + self.assertTrue(1/(42 + fp("1e-20", 20) - 42) == fp("100.0E18")) o = fp(".9995", 4) - self.assert_(1 - o == fp("5e-4", 10)) + self.assertTrue(1 - o == fp("5e-4", 10)) o.set_precision(3) - self.assert_(o == 1) + self.assertTrue(o == 1) o = fp(".9985", 4) o.set_precision(3) - self.assert_(o == fp(".998", 10)) - self.assert_(o == o.frac()) + self.assertTrue(o == fp(".998", 10)) + self.assertTrue(o == o.frac()) o.set_precision(100) - self.assert_(o == fp(".998", 10)) + self.assertTrue(o == fp(".998", 10)) o.set_precision(2) - self.assert_(o == 1) + self.assertTrue(o == 1) x = fp(1.99) - self.assert_(long(x) == -long(-x) == 1L) - self.assert_(int(x) == -int(-x) == 1) - self.assert_(x == long(x) + x.frac()) - self.assert_(-x == long(-x) + (-x).frac()) - self.assert_(fp(7) % 4 == 7 % fp(4) == 3) - self.assert_(fp(-7) % 4 == -7 % fp(4) == 1) - self.assert_(fp(-7) % -4 == -7 % fp(-4) == -3) - self.assert_(fp(7.0) % "-4.0" == 7 % fp(-4) == -1) - self.assert_(fp("5.5") % fp("1.1") == fp("5.5e100") % fp("1.1e100") == 0) - self.assert_(divmod(fp("1e100"), 3) == (long(fp("1e100")/3), 1)) + self.assertTrue(int(x) == -int(-x) == 1) + self.assertTrue(int(x) == -int(-x) == 1) + self.assertTrue(x == int(x) + x.frac()) + self.assertTrue(-x == int(-x) + (-x).frac()) + self.assertTrue(fp(7) % 4 == 7 % fp(4) == 3) + self.assertTrue(fp(-7) % 4 == -7 % fp(4) == 1) + self.assertTrue(fp(-7) % -4 == -7 % fp(-4) == -3) + self.assertTrue(fp(7.0) % "-4.0" == 7 % fp(-4) == -1) + self.assertTrue(fp("5.5") % fp("1.1") == fp("5.5e100") % fp("1.1e100") == 0) + self.assertTrue(divmod(fp("1e100"), 3) == (int(fp("1e100")/3), 1)) --- ./fixedpoint.py (original) +++ ./fixedpoint.py (refactored) @@ -183,8 +183,8 @@ self.n = n return - if isinstance(value, type(42)) or isinstance(value, type(42L)): - self.n = long(value) * _tento(p) + if isinstance(value, type(42)) or isinstance(value, type(42)): + self.n = int(value) * _tento(p) return if isinstance(value, type(self)): @@ -204,7 +204,7 @@ # up all bits in 2 iterations for all known binary double- # precision formats, and small enough to fit in an int. CHUNK = 28 - top = 0L + top = 0 # invariant: |value| = (top + f) * 2**e exactly while f: f = math.ldexp(f, CHUNK) @@ -222,7 +222,7 @@ if e >= 0: n = top << e else: - n = self._roundquotient(top, 1L << -e) + n = self._roundquotient(top, 1 << -e) if value < 0: n = -n self.n = n @@ -230,7 +230,7 @@ if isinstance(value, type(42-42j)): raise TypeError("can't convert complex to FixedPoint: " + - `value`) + repr(value)) # can we coerce to a float? yes = 1 @@ -245,14 +245,14 @@ # similarly for long yes = 1 try: - aslong = long(value) + aslong = int(value) except: yes = 0 if yes: self.__init__(aslong, p) return - raise TypeError("can't convert to FixedPoint: " + `value`) + raise TypeError("can't convert to FixedPoint: " + repr(value)) def get_precision(self): """Return the precision of this FixedPoint. @@ -277,9 +277,9 @@ p = int(preciRefactoringTool: Refactored ./examples/roundingsample.py sion) except: raise TypeError("precision not convertable to int: " + - `precision`) + repr(precision)) if p < 0: - raise ValueError("precision must be >= 0: " + `precision`) + raise ValueError("precision must be >= 0: " + repr(precision)) if p > self.p: self.n = self.n * _tento(p - self.p) @@ -302,7 +302,7 @@ "." + frac def __repr__(self): - return "FixedPoint" + `(str(self), self.p)` + return "FixedPoint" + repr((str(self), self.p)) def copy(self): return _mkFP(self.n, self.p, type(self)) @@ -333,7 +333,7 @@ n, p = self.__reduce() return hash(n) ^ hash(p) - def __nonzero__(self): + def __bool__(self): """ Returns true if this FixedPoint is not equal to zero""" return self.n != 0 @@ -429,7 +429,7 @@ x.frac() + long(x) == x """ - return self - long(self) + return self - int(self) def _roundquotient(self, x, y): """ @@ -462,7 +462,7 @@ try: return cache[n] except KeyError: - answer = cache[n] = 10L ** n + answer = cache[n] = 10 ** n return answer def _norm(x, y, isinstance=isinstance, FixedPoint=FixedPoint, @@ -528,7 +528,7 @@ """Return n, p s.t. float string value == n * 10**p exactly.""" m = _parser(s) if m is None: - raise ValueError("can't parse as number: " + `s`) + raise ValueError("can't parse as number: " + repr(s)) exp = m.group('exp') if exp is None: @@ -547,7 +547,7 @@ assert intpart assert fracpart - i, f = long(intpart), long(fracpart) + i, f = int(intpart), int(fracpart) nfrac = len(fracpart) i = i * _tento(nfrac) + f exp = exp - nfrac @@ -582,8 +582,8 @@ assert 1 + o == o + 1 == fp(" +00.000011e+5 ") assert 1/o == 10 assert o + t == t + o == -o - assert 2.0 * t == t * 2 == "2" * t == o/o * 2L * t - assert 1 - t == -(t - 1) == fp(6L)/5 + assert 2.0 * t == t * 2 == "2" * t == o/o * 2 * t + assert 1 - t == -(t - 1) == fp(6)/5 assert t*t == 4*o*o == o*4*o == o*o*4 assert fp(2) - "1" == 1 assert float(-1/t) == 5.0 @@ -603,16 +603,16 @@ o.set_precision(2) assert o == 1 x = fp(1.99) - assert long(x) == -long(-x) == 1L assert int(x) == -int(-x) == 1 - assert x == long(x) + x.frac() - assert -x == long(-x) + (-x).frac() + assert int(x) == -int(-x) == 1 + assert x == int(x) + x.frac() + assert -x == int(-x) + (-x).frac() assert fp(7) % 4 == 7 % fp(4) == 3 assert fp(-7) % 4 == -7 % fp(4) == 1 assert fp(-7) % -4 == -7 % fp(-4) == -3 assert fp(7.0) % "-4.0" == 7 % fp(-4) == -1 assert fp("5.5") % fp("1.1") == fp("5.5e100") % fp("1.1e100") == 0 - assert divmod(fp("1e100"), 3) == (long(fp("1e100")/3), 1) + assert divmod(fp("1e100"), 3) == (int(fp("1e100")/3), 1) if __name__ == '__main__': _test() --- ./examples/roundingsample.py (original) +++ ./examples/roundingsample.py (refactored) @@ -16,29 +16,29 @@ FORMAT = "FixedPoint(%s, 0) = %s" def testFunction(s): - print FORMAT % (s, FixedPoint(s, 0)) + print(FORMAT % (s, FixedPoint(s, 0))) SAMPLE_DATA = [ "-4.5", "-3.5", "-2.5", "-1.5", "-0.5", "0.5", "1.5", "2.5", "3.5", "4.5" ] -print "Banker's Rounding" +print("Banker's Rounding") FixedPoint.round = bankersRounding -map(testFunction, SAMPLE_DATA) +list(map(testFunction, SAMPLE_DATA)) -print -print +print() +print() -print "Round Away from Zero (add half and chop)" +print("Round Away from Zero (add half and chop)") FixedPoint.round = addHalfAndChop -map(testFunction, SAMPLE_DATA) +list(map(testFunction, SAMPLE_DATA)) -print -print +print() +print() -print "Developer defined rounding -- truncate" +print("Developer defined rounding -- truncate") def truncate(self, dividend, divisor, quotient, remainder): """Don't round: truncate""" @@ -50,6 +50,6 @@ FixedPoint.round RefactoringTool: Refactored ./examples/FPbench.py RefactoringTool: Refactored ./FixedPoint.original.py = truncate -map(testFunction, SAMPLE_DATA) +list(map(testFunction, SAMPLE_DATA)) --- ./examples/FPbench.py (original) +++ ./examples/FPbench.py (refactored) @@ -24,11 +24,11 @@ eval(tstExec) NullTest=("Null Time", "123.123","Null Time (%i execs of floating point): %7.5f secs. (%8.3f ops/sec.)") -if VERBOSE: print "Starting: ", NullTest[0] +if VERBOSE: print("Starting: ", NullTest[0]) start_time = clock() run_test(NullTest) nulltime = clock() - start_time -print NullTest[2] % (LOOPCNT,nulltime, LOOPCNT/nulltime) +print(NullTest[2] % (LOOPCNT,nulltime, LOOPCNT/nulltime)) TestDefList = ( @@ -49,14 +49,14 @@ ) #end of TestDefList for testdef in TestDefList: - if VERBOSE: print 'Starting: %s' % testdef[0] + if VERBOSE: print('Starting: %s' % testdef[0]) start_time = clock() run_test(testdef) test_time = clock() - start_time - nulltime - print testdef[2] % (LOOPCNT, test_time), + print(testdef[2] % (LOOPCNT, test_time), end=' ') try: - print "(%8.3f ops/sec.)" % (LOOPCNT/test_time,) + print("(%8.3f ops/sec.)" % (LOOPCNT/test_time,)) except ZeroDivisionError: - print "(N/A ops/sec.)" + print("(N/A ops/sec.)") --- ./FixedPoint.original.py (original) +++ ./FixedPoint.original.py (refactored) @@ -144,8 +144,8 @@ self.n = n return - if isinstance(value, type(42)) or isinstance(value, type(42L)): - self.n = long(value) * _tento(p) + if isinstance(value, type(42)) or isinstance(value, type(42)): + self.n = int(value) * _tento(p) return if isinstance(value, FixedPoint): @@ -165,7 +165,7 @@ # up all bits in 2 iterations for all known binary double- # precision formats, and small enough to fit in an int. CHUNK = 28 - top = 0L + top = 0 # invariant: |value| = (top + f) * 2**e exactly while f: f = math.ldexp(f, CHUNK) @@ -183,7 +183,7 @@ if e >= 0: n = top << e else: - n = _roundquotient(top, 1L << -e) + n = _roundquotient(top, 1 << -e) if value < 0: n = -n self.n = n @@ -191,7 +191,7 @@ if isinstance(value, type(42-42j)): raise TypeError("can't convert complex to FixedPoint: " + - `value`) + repr(value)) # can we coerce to a float? yes = 1 @@ -206,14 +206,14 @@ # similarly for long yes = 1 try: - aslong = long(value) + aslong = int(value) except: yes = 0 if yes: self.__init__(aslong, p) return - raise TypeError("can't convert to FixedPoint: " + `value`) + raise TypeError("can't convert to FixedPoint: " + repr(value)) def get_precision(self): """Return the precision of this FixedPoint. @@ -238,9 +238,9 @@ p = int(precision) except: raise TypeError("precision not convertable to int: " + - `precision`) + repr(precision)) if p < 0: - raise ValueError("precision must be >= 0: " + `precision`) + raise ValueError("precision must be >= 0: " + repr(precision)) if p > self.p: self.n = self.n * _tento(p - self.p) @@ -261,7 +261,7 @@ "." + frac def __repr__(self): - return "FixedPoint" + `(str(self), self.p)` + return "FixedPoint" + repr((str(self), self.p)) def copy(self): return _mkFP(self.n, self.p) @@ -287,7 +287,7 @@ # a float, their hashes may differ. This is a teensy bit Bad. return hash(n) ^ hash(p) - def __nonzero__(self): + def __bool__(self): return self.n != 0 def __neg__(self): @@ -377,7 +377,7 @@ x.frac() + long(x) == x """ - retuRefactoringTool: Files that were modified: RefactoringTool: ./test_fixedpoint.py RefactoringTool: ./fixedpoint.py RefactoringTool: ./examples/roundingsample.py RefactoringTool: ./examples/FPbench.py RefactoringTool: ./FixedPoint.original.py RefactoringTool: Warnings/messages while refactoring: RefactoringTool: ### In file ./examples/roundingsample.py ### RefactoringTool: Line 28: You should use a for loop here RefactoringTool: Line 36: You should use a for loop here RefactoringTool: Line 53: You should use a for loop here rn self - long(self) + return self - int(self) # return n, p s.t. self == n/10**p and n % 10 != 0 def __reduce(self): @@ -395,7 +395,7 @@ try: return cache[n] except KeyError: - answer = cache[n] = 10L ** n + answer = cache[n] = 10 ** n return answer # return xn, yn, p s.t. @@ -472,7 +472,7 @@ def _string2exact(s): m = _parser(s) if m is None: - raise ValueError("can't parse as number: " + `s`) + raise ValueError("can't parse as number: " + repr(s)) exp = m.group('exp') if exp is None: @@ -491,7 +491,7 @@ assert intpart assert fracpart - i, f = long(intpart), long(fracpart) + i, f = int(intpart), int(fracpart) nfrac = len(fracpart) i = i * _tento(nfrac) + f exp = exp - nfrac @@ -525,8 +525,8 @@ assert 1 + o == o + 1 == fp(" +00.000011e+5 ") assert 1/o == 10 assert o + t == t + o == -o - assert 2.0 * t == t * 2 == "2" * t == o/o * 2L * t - assert 1 - t == -(t - 1) == fp(6L)/5 + assert 2.0 * t == t * 2 == "2" * t == o/o * 2 * t + assert 1 - t == -(t - 1) == fp(6)/5 assert t*t == 4*o*o == o*4*o == o*o*4 assert fp(2) - "1" == 1 assert float(-1/t) == 5.0 @@ -546,16 +546,16 @@ o.set_precision(2) assert o == 1 x = fp(1.99) - assert long(x) == -long(-x) == 1L assert int(x) == -int(-x) == 1 - assert x == long(x) + x.frac() - assert -x == long(-x) + (-x).frac() + assert int(x) == -int(-x) == 1 + assert x == int(x) + x.frac() + assert -x == int(-x) + (-x).frac() assert fp(7) % 4 == 7 % fp(4) == 3 assert fp(-7) % 4 == -7 % fp(4) == 1 assert fp(-7) % -4 == -7 % fp(-4) == -3 assert fp(7.0) % "-4.0" == 7 % fp(-4) == -1 assert fp("5.5") % fp("1.1") == fp("5.5e100") % fp("1.1e100") == 0 - assert divmod(fp("1e100"), 3) == (long(fp("1e100")/3), 1) + assert divmod(fp("1e100"), 3) == (int(fp("1e100")/3), 1) if __name__ == '__main__': _test() ++ find ./ -name '*.py' + sed -i 's|#!/usr/bin/env python|#!/usr/bin/env python3|' ./test_fixedpoint.py ./fixedpoint.py ./examples/roundingsample.py ./examples/FPbench.py ./FixedPoint.original.py + exit 0 Executing(%build): /bin/sh -e /usr/src/tmp/rpm-tmp.53057 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + cd fixedpoint + /usr/bin/python3 test_fixedpoint.py EE.EE...EFFEFEEEEEEE.EEEEEEEEEEEEEFE ====================================================================== ERROR: testAddHalfAndChop (__main__.FixedPointTest) test that 'add half and chop' rounding works as expected ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 776, in testAddHalfAndChop FixedPoint(1.5,0), FixedPoint(2.0,0)) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 145, in addHalfAndChop c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: testBankersRounding (__main__.FixedPointTest) test that bankers rounding works as expected ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 764, in testBankersRounding FixedPoint(1.5,0), FixedPoint(2.0,0)) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: testCreateFromFixedPoint (__main__.FixedPointTest) Create a FixedPoint from another FixedPoint ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 103, in testCreateFromFixedPoint x = SonOfFixedPoint(n); File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 20, in __init__ FixedPoint.__init__(self, value, precision) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 242, in __init__ self.__init__(asfloat, p) File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 20, in __init__ FixedPoint.__init__(self, value, precision) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: testCreateFromFloat (__main__.FixedPointTest) Create a FixedPoint from a floating point number ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 116, in testCreateFromFloat n = FixedPoint(42.3e5); File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: testCreateFromString (__main__.FixedPointTest) Create a FixedPoint from a string ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 68, in testCreateFromString n = FixedPoint("42.123"); File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 182, in __init__ n = self._roundquotient(n, _tento(-effective_exp)) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: testSetAndGetPrecision (__main__.FixedPointTest) Change and retrieve the precision of an existin object ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 142, in testSetAndGetPrecision n = FixedPoint(42.3e-1); File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__add__ (__main__.FixedPointTest) test addition ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 340, in test__add__ a = FixedPoint(3.33) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__cmp__ (__main__.FixedPointTest) test compare ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 275, in test__cmp__ self.assertFalse(a < b) TypeError: '<' not supported between instances of 'FixedPoint' and 'FixedPoint' ====================================================================== ERROR: test__copy__ (__main__.FixedPointTest) test shallow copy ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 244, in test__copy__ n = FixedPoint(-4.23); File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__deepcopy__ (__main__.FixedPointTest) test deep copy ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 258, in test__deepcopy__ n = FixedPoint(-4.23); File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__div__ (__main__.FixedPointTest) test division ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 587, in test__div__ a = FixedPoint(6.66) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__divmod__ (__main__.FixedPointTest) test integer division with modulo ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 673, in test__divmod__ a = FixedPoint(3.33) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__float__ (__main__.FixedPointTest) test casting to float ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 738, in test__float__ self.assertEqual(3.1416, float(FixedPoint(3.14159, 4))) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__int__ (__main__.FixedPointTest) test casting to int ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 748, in test__int__ self.assertEqual(3, int(FixedPoint(3.14159, 4))) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__long__ (__main__.FixedPointTest) test casting to long ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 743, in test__long__ self.assertEqual(3, int(FixedPoint(3.14159, 4))) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__mod__ (__main__.FixedPointTest) test modulo ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 713, in test__mod__ a = FixedPoint(3.33) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__mul__ (__main__.FixedPointTest) test multiplication ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 507, in test__mul__ c = a * b File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 366, in __mul__ n1, n2, p = _norm(self, other, FixedPoint=type(self)) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 482, in _norm y = FixedPoint(y, x.p) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__neg__ (__main__.FixedPointTest) test negative ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 323, in test__neg__ self.assertTrue(-FixedPoint(-1.0e-15, 15)) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__nonzero__ (__main__.FixedPointTest) test the truth value ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 314, in test__nonzero__ self.assertTrue(FixedPoint(1.0e-15, 15)) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__radd__ (__main__.FixedPointTest) test addition as the right argument ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 400, in test__radd__ a = FixedPoint(3.33) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__rdiv__ (__main__.FixedPointTest) test right division ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 659, in test__rdiv__ c = b / a TypeError: unsupported operand type(s) for /: 'int' and 'FixedPoint' ====================================================================== ERROR: test__rdivmod__ (__main__.FixedPointTest) test right integer division with modulo ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 706, in test__rdivmod__ a = FixedPoint(3.33) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__repr__ (__main__.FixedPointTest) test representation ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 210, in test__repr__ n = FixedPoint(42.3e-1); File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__rmod__ (__main__.FixedPointTest) test right modulo ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 725, in test__rmod__ a = FixedPoint(3.33) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__rmul__ (__main__.FixedPointTest) test multiplication ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 568, in test__rmul__ a = FixedPoint(3.33) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__rsub__ (__main__.FixedPointTest) test subtraction as the right hand argument ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 486, in test__rsub__ a = FixedPoint(3.33) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== ERROR: test__sub__ (__main__.FixedPointTest) test subtraction ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 420, in test__sub__ a = FixedPoint(3.33) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 225, in __init__ n = self._roundquotient(top, 1 << -e) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 443, in _roundquotient return self.round(x, y, n, leftover) File "/usr/src/RPM/BUILD/fixedpoint/fixedpoint.py", line 132, in bankersRounding c = cmp(remainder << 1, divisor) NameError: name 'cmp' is not defined ====================================================================== FAIL: testFrac (__main__.FixedPointTest) test return of the fractional portion ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 752, in testFrac self.assertEqual( AssertionError: FixedPoint('.00', 2) != FixedPoint('.00', 2) ====================================================================== FAIL: testOriginal (__main__.FixedPointTest) Tim's oringinal tests in __main__ of fixedpoint.py ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 786, in testOriginal self.assertTrue(str(o) == "0.10") AssertionError: False is not true ====================================================================== FAIL: test__abs__ (__main__.FixedPointTest) test absolute value ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 330, in test__abs__ self.assertEqual(abs(d), d) AssertionError: FixedPoint('.00', 2) != FixedPoint('.00', 2) ====================================================================== FAIL: test__str__ (__main__.FixedPointTest) test conversion to string ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/src/RPM/BUILD/fixedpoint/test_fixedpoint.py", line 180, in test__str__ self.assertEqual(str(n), "0.00") AssertionError: '.00' != '0.00' - .00 + 0.00 ? + ---------------------------------------------------------------------- Ran 36 tests in 0.008s FAILED (failures=4, errors=27) + exit 0 Executing(%install): /bin/sh -e /usr/src/tmp/rpm-tmp.14007 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + /bin/chmod -Rf u+rwX -- /usr/src/tmp/python3-module-fixedpoint-buildroot + : + /bin/rm -rf -- /usr/src/tmp/python3-module-fixedpoint-buildroot + PATH=/usr/libexec/rpm-build:/usr/src/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/games + cd fixedpoint + mkdir -p /usr/src/tmp/python3-module-fixedpoint-buildroot/usr/lib/python3/site-packages + install -m644 fixedpoint.py /usr/src/tmp/python3-module-fixedpoint-buildroot/usr/lib/python3/site-packages/ + /usr/lib/rpm/brp-alt Cleaning files in /usr/src/tmp/python3-module-fixedpoint-buildroot (auto) Verifying and fixing files in /usr/src/tmp/python3-module-fixedpoint-buildroot (binconfig,pkgconfig,libtool,desktop,gnuconfig) Checking contents of files in /usr/src/tmp/python3-module-fixedpoint-buildroot/ (default) Compressing files in /usr/src/tmp/python3-module-fixedpoint-buildroot (auto) Adjusting library links in /usr/src/tmp/python3-module-fixedpoint-buildroot ./usr/lib: (from :0) Verifying ELF objects in /usr/src/tmp/python3-module-fixedpoint-buildroot (arch=normal,fhs=normal,lfs=relaxed,lint=relaxed,rpath=normal,stack=normal,textrel=normal,unresolved=normal) Bytecompiling python3 modules in /usr/src/tmp/python3-module-fixedpoint-buildroot using /usr/bin/python3 compile /usr/src/tmp/python3-module-fixedpoint-buildroot/usr/lib/python3/site-packages/fixedpoint.py Bytecompiling python3 modules with optimization in /usr/src/tmp/python3-module-fixedpoint-buildroot using /usr/bin/python3 -O compile /usr/src/tmp/python3-module-fixedpoint-buildroot/usr/lib/python3/site-packages/fixedpoint.py Bytecompiling python3 modules with optimization-2 in /usr/src/tmp/python3-module-fixedpoint-buildroot using /usr/bin/python3 -OO compile /usr/src/tmp/python3-module-fixedpoint-buildroot/usr/lib/python3/site-packages/fixedpoint.py Hardlinking identical .pyc and .opt-?.pyc files Processing files: python3-module-fixedpoint-0.1.2-alt3 Executing(%doc): /bin/sh -e /usr/src/tmp/rpm-tmp.51810 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + cd fixedpoint + DOCDIR=/usr/src/tmp/python3-module-fixedpoint-buildroot/usr/share/doc/python3-module-fixedpoint-0.1.2 + export DOCDIR + rm -rf /usr/src/tmp/python3-module-fixedpoint-buildroot/usr/share/doc/python3-module-fixedpoint-0.1.2 + /bin/mkdir -p /usr/src/tmp/python3-module-fixedpoint-buildroot/usr/share/doc/python3-module-fixedpoint-0.1.2 + cp -prL README examples /usr/src/tmp/python3-module-fixedpoint-buildroot/usr/share/doc/python3-module-fixedpoint-0.1.2 + chmod -R go-w /usr/src/tmp/python3-module-fixedpoint-buildroot/usr/share/doc/python3-module-fixedpoint-0.1.2 + chmod -R a+rX /usr/src/tmp/python3-module-fixedpoint-buildroot/usr/share/doc/python3-module-fixedpoint-0.1.2 + exit 0 Finding Provides (using /usr/lib/rpm/find-provides) Executing: /bin/sh -e /usr/src/tmp/rpm-tmp.s5I8U3 find-provides: running scripts (alternatives,debuginfo,lib,pam,perl,pkgconfig,python,python3,shell) Finding Requires (using /usr/lib/rpm/find-requires) Executing: /bin/sh -e /usr/src/tmp/rpm-tmp.TduaS7 find-requires: running scripts (cpp,debuginfo,files,lib,pam,perl,pkgconfig,pkgconfiglib,python,python3,rpmlib,shebang,shell,static,symlinks,systemd-services) /usr/lib/rpm/python3.req.py:6: DeprecationWarning: The parser module is deprecated and will be removed in future versions of Python import parser, symbol, token, types /usr/lib/rpm/python3.req.py:6: DeprecationWarning: The symbol module is deprecated and will be removed in future versions of Python import parser, symbol, token, types /usr/lib/rpm/python3.req.py: /usr/src/tmp/python3-module-fixedpoint-buildroot/usr/lib/python3/site-packages/fixedpoint.py: line=198 IGNORE (for REQ=slight and deep=15) module=math shebang.req.files: executable script /usr/src/tmp/python3-module-fixedpoint-buildroot/usr/lib/python3/site-packages/fixedpoint.py is not executable Provides: python3(fixedpoint) Requires: /usr/lib/python3/site-packages, python3(re) < 0 Finding debuginfo files (using /usr/lib/rpm/find-debuginfo-files) Executing: /bin/sh -e /usr/src/tmp/rpm-tmp.9Z41k4 Wrote: /usr/src/RPM/RPMS/i586/python3-module-fixedpoint-0.1.2-alt3.i586.rpm (w2.lzdio) 5.31user 0.33system 0:10.84elapsed 52%CPU (0avgtext+0avgdata 18460maxresident)k 0inputs+0outputs (0major+128314minor)pagefaults 0swaps /.out/python3-module-fixedpoint-0.1.2-alt3.i586.rpm: license not found in '/usr/share/license' directory: Distributable 11.57user 2.85system 0:24.76elapsed 58%CPU (0avgtext+0avgdata 101080maxresident)k 0inputs+0outputs (0major+484523minor)pagefaults 0swaps --- python3-module-fixedpoint-0.1.2-alt3.i586.rpm.repo 2019-11-05 11:47:16.694996375 +0000 +++ python3-module-fixedpoint-0.1.2-alt3.i586.rpm.hasher 2021-09-14 10:12:00.748540348 +0000 @@ -1,4 +1,4 @@ -/usr/lib/python3/site-packages/__pycache__/fixedpoint.cpython-37.opt-1.pyc 100644 root:root -/usr/lib/python3/site-packages/__pycache__/fixedpoint.cpython-37.opt-2.pyc 100644 root:root -/usr/lib/python3/site-packages/__pycache__/fixedpoint.cpython-37.pyc 100644 root:root +/usr/lib/python3/site-packages/__pycache__/fixedpoint.cpython-39.opt-1.pyc 100644 root:root +/usr/lib/python3/site-packages/__pycache__/fixedpoint.cpython-39.opt-2.pyc 100644 root:root +/usr/lib/python3/site-packages/__pycache__/fixedpoint.cpython-39.pyc 100644 root:root /usr/lib/python3/site-packages/fixedpoint.py 100644 root:root @@ -14,5 +14,5 @@ Provides: python3-module-fixedpoint = 0.1.2-alt3:sisyphus+240220.100.1.1 -File: /usr/lib/python3/site-packages/__pycache__/fixedpoint.cpython-37.opt-1.pyc 100644 root:root 48a8dbf164bc369ef7efb3e512b5f934 -File: /usr/lib/python3/site-packages/__pycache__/fixedpoint.cpython-37.opt-2.pyc 100644 root:root f7fb950b6eeb3c61fde6cf932cd33a82 -File: /usr/lib/python3/site-packages/__pycache__/fixedpoint.cpython-37.pyc 100644 root:root ee5bfee28cac75eca8d12948ab93beba +File: /usr/lib/python3/site-packages/__pycache__/fixedpoint.cpython-39.opt-1.pyc 100644 root:root c9bc6ceb18f3de6b91d33a8a23f03314 +File: /usr/lib/python3/site-packages/__pycache__/fixedpoint.cpython-39.opt-2.pyc 100644 root:root e0169af92096bec56a7b8543c73644c2 +File: /usr/lib/python3/site-packages/__pycache__/fixedpoint.cpython-39.pyc 100644 root:root 0036904042bbfe98d91daebec66143cc File: /usr/lib/python3/site-packages/fixedpoint.py 100644 root:root ab153b03dace202e698d2d9ff0e3d508 @@ -23,2 +23,2 @@ File: /usr/share/doc/python3-module-fixedpoint-0.1.2/examples/roundingsample.py 100755 root:root 34d633434d882992aa7cd61b9a652ed3 -RPMIdentity: 2f85b44f93fa7d3d151b45b4f8be42a83889c916fed678b21cff57ba9e38c5f3aafed44be36027d12119c26c6c108eebcaeb674129ba7e3cbebe6bfa234ab5e3 +RPMIdentity: 92967f021da5ba7b8af05ab8836402e76bb0d7de4a489fdbd72a5367582f4842f6220e0d08b933b9878c35f92bbd5329b8906fcfece15f3dbdc37826b20bb118