Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
ca666245
Kaydet (Commit)
ca666245
authored
Şub 29, 2012
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#14089: increase coverage of the fractions module. Patch by Oleg Plakhotnyuk.
üst
d9de93eb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
test_fractions.py
Lib/test/test_fractions.py
+19
-1
No files found.
Lib/test/test_fractions.py
Dosyayı görüntüle @
ca666245
...
...
@@ -6,6 +6,7 @@ import math
import
numbers
import
operator
import
fractions
import
sys
import
unittest
from
copy
import
copy
,
deepcopy
from
cPickle
import
dumps
,
loads
...
...
@@ -88,6 +89,9 @@ class DummyRational(object):
__hash__
=
None
class
DummyFraction
(
fractions
.
Fraction
):
"""Dummy Fraction subclass for copy and deepcopy testing."""
class
GcdTest
(
unittest
.
TestCase
):
def
testMisc
(
self
):
...
...
@@ -301,11 +305,15 @@ class FractionTest(unittest.TestCase):
self
.
assertEqual
(
F
(
201
,
200
)
.
limit_denominator
(
100
),
F
(
1
))
self
.
assertEqual
(
F
(
201
,
200
)
.
limit_denominator
(
101
),
F
(
102
,
101
))
self
.
assertEqual
(
F
(
0
)
.
limit_denominator
(
10000
),
F
(
0
))
for
i
in
(
0
,
-
1
):
self
.
assertRaisesMessage
(
ValueError
,
"max_denominator should be at least 1"
,
F
(
1
)
.
limit_denominator
,
i
)
def
testConversions
(
self
):
self
.
assertTypedEquals
(
-
1
,
math
.
trunc
(
F
(
-
11
,
10
)))
self
.
assertTypedEquals
(
-
1
,
int
(
F
(
-
11
,
10
)))
self
.
assertTypedEquals
(
1
,
math
.
trunc
(
F
(
11
,
10
)))
self
.
assertEqual
(
False
,
bool
(
F
(
0
,
1
)))
self
.
assertEqual
(
True
,
bool
(
F
(
3
,
2
)))
self
.
assertTypedEquals
(
0.1
,
float
(
F
(
1
,
10
)))
...
...
@@ -330,6 +338,7 @@ class FractionTest(unittest.TestCase):
self
.
assertEqual
(
F
(
8
,
27
),
F
(
2
,
3
)
**
F
(
3
))
self
.
assertEqual
(
F
(
27
,
8
),
F
(
2
,
3
)
**
F
(
-
3
))
self
.
assertTypedEquals
(
2.0
,
F
(
4
)
**
F
(
1
,
2
))
self
.
assertEqual
(
F
(
1
,
1
),
+
F
(
1
,
1
))
# Will return 1j in 3.0:
self
.
assertRaises
(
ValueError
,
pow
,
F
(
-
1
),
F
(
1
,
2
))
...
...
@@ -394,6 +403,10 @@ class FractionTest(unittest.TestCase):
TypeError
,
"unsupported operand type(s) for +: 'Fraction' and 'Decimal'"
,
operator
.
add
,
F
(
3
,
11
),
Decimal
(
'3.1415926'
))
self
.
assertRaisesMessage
(
TypeError
,
"unsupported operand type(s) for +: 'Decimal' and 'Fraction'"
,
operator
.
add
,
Decimal
(
'3.1415926'
),
F
(
3
,
11
))
self
.
assertNotEqual
(
F
(
5
,
2
),
Decimal
(
'2.5'
))
def
testComparisons
(
self
):
...
...
@@ -571,9 +584,14 @@ class FractionTest(unittest.TestCase):
def
test_copy_deepcopy_pickle
(
self
):
r
=
F
(
13
,
7
)
dr
=
DummyFraction
(
13
,
7
)
self
.
assertEqual
(
r
,
loads
(
dumps
(
r
)))
self
.
assertEqual
(
id
(
r
),
id
(
copy
(
r
)))
self
.
assertEqual
(
id
(
r
),
id
(
deepcopy
(
r
)))
self
.
assertNotEqual
(
id
(
dr
),
id
(
copy
(
dr
)))
self
.
assertNotEqual
(
id
(
dr
),
id
(
deepcopy
(
dr
)))
self
.
assertTypedEquals
(
dr
,
copy
(
dr
))
self
.
assertTypedEquals
(
dr
,
deepcopy
(
dr
))
def
test_slots
(
self
):
# Issue 4998
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment