summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_fractions.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-01-16 10:02:51 (GMT)
committerGitHub <noreply@github.com>2020-01-16 10:02:51 (GMT)
commit4691a2f2a2b8174a6c958ce6976ed5f3354c9504 (patch)
tree2d39ff21b819f1da2940d94b574190e89a9cf079 /Lib/test/test_fractions.py
parent210c19e3c5b86535a73487fa737752de8eb1d866 (diff)
downloadcpython-4691a2f2a2b8174a6c958ce6976ed5f3354c9504.zip
cpython-4691a2f2a2b8174a6c958ce6976ed5f3354c9504.tar.gz
cpython-4691a2f2a2b8174a6c958ce6976ed5f3354c9504.tar.bz2
bpo-39350: Remove deprecated fractions.gcd() (GH-18021)
Remove fractions.gcd() function, deprecated since Python 3.5 (bpo-22486): use math.gcd() instead.
Diffstat (limited to 'Lib/test/test_fractions.py')
-rw-r--r--Lib/test/test_fractions.py27
1 files changed, 2 insertions, 25 deletions
diff --git a/Lib/test/test_fractions.py b/Lib/test/test_fractions.py
index 18ab28c..7cf7899 100644
--- a/Lib/test/test_fractions.py
+++ b/Lib/test/test_fractions.py
@@ -12,7 +12,7 @@ import warnings
from copy import copy, deepcopy
from pickle import dumps, loads
F = fractions.Fraction
-gcd = fractions.gcd
+
class DummyFloat(object):
"""Dummy float class for testing comparisons with Fractions"""
@@ -81,30 +81,6 @@ class DummyRational(object):
class DummyFraction(fractions.Fraction):
"""Dummy Fraction subclass for copy and deepcopy testing."""
-class GcdTest(unittest.TestCase):
-
- def testMisc(self):
- # fractions.gcd() is deprecated
- with self.assertWarnsRegex(DeprecationWarning, r'fractions\.gcd'):
- gcd(1, 1)
- with warnings.catch_warnings():
- warnings.filterwarnings('ignore', r'fractions\.gcd',
- DeprecationWarning)
- self.assertEqual(0, gcd(0, 0))
- self.assertEqual(1, gcd(1, 0))
- self.assertEqual(-1, gcd(-1, 0))
- self.assertEqual(1, gcd(0, 1))
- self.assertEqual(-1, gcd(0, -1))
- self.assertEqual(1, gcd(7, 1))
- self.assertEqual(-1, gcd(7, -1))
- self.assertEqual(1, gcd(-23, 15))
- self.assertEqual(12, gcd(120, 84))
- self.assertEqual(-12, gcd(84, -120))
- self.assertEqual(gcd(120.0, 84), 12.0)
- self.assertEqual(gcd(120, 84.0), 12.0)
- self.assertEqual(gcd(F(120), F(84)), F(12))
- self.assertEqual(gcd(F(120, 77), F(84, 55)), F(12, 385))
-
def _components(r):
return (r.numerator, r.denominator)
@@ -690,5 +666,6 @@ class FractionTest(unittest.TestCase):
r = F(13, 7)
self.assertRaises(AttributeError, setattr, r, 'a', 10)
+
if __name__ == '__main__':
unittest.main()