MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_init

Method test_init

Lib/test/test_enum.py:2614–2633  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2612 grene = 2
2613
2614 def test_init(self):
2615 class Planet(Enum):
2616 MERCURY = (3.303e+23, 2.4397e6)
2617 VENUS = (4.869e+24, 6.0518e6)
2618 EARTH = (5.976e+24, 6.37814e6)
2619 MARS = (6.421e+23, 3.3972e6)
2620 JUPITER = (1.9e+27, 7.1492e7)
2621 SATURN = (5.688e+26, 6.0268e7)
2622 URANUS = (8.686e+25, 2.5559e7)
2623 NEPTUNE = (1.024e+26, 2.4746e7)
2624 def __init__(self, mass, radius):
2625 self.mass = mass # in kilograms
2626 self.radius = radius # in meters
2627 @enum.property
2628 def surface_gravity(self):
2629 # universal gravitational constant (m3 kg-1 s-2)
2630 G = 6.67300E-11
2631 return G * self.mass / (self.radius * self.radius)
2632 self.assertEqual(round(Planet.EARTH.surface_gravity, 2), 9.80)
2633 self.assertEqual(Planet.EARTH.value, (5.976e+24, 6.37814e6))
2634
2635 def test_ignore(self):
2636 class Period(timedelta, Enum):

Callers

nothing calls this directly

Calls 2

roundFunction · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected