def test600_930ShouldRaiseExceptionOnNonNumericT(self): expectedString = "Sample.p:" mySample = SM.Sample(self.nominalN) with self.assertRaises(ValueError) as context: mySample.p(t="abc", tails=1) self.assertEquals(expectedString, context.exception.args[0][0:len(expectedString)])
def test000_002_ShouldIntegrateSquare(self): s = SM.Sample(self.nominalN) self.assertAlmostEquals(s.integrate(0.0, 1.0, 1.0, lambda x, y: x**2), 1.0 / 3.0)
def test400_020_ShouldCalculateF(self): mySample = SM.Sample(self.nominalN) self.assertAlmostEquals(mySample.f(1, 5), 0.578703704)
def test400_010_ShouldCalculateFStarterCase(self): mySample = SM.Sample(self.nominalN) self.assertAlmostEquals(mySample.f(0, 5), 1, 4)
def test300_010_ShouldCalculateLHP(self): mySample = SM.Sample(self.nominalN) self.assertAlmostEquals(mySample.calculateConstant(5), 0.37960669, 4)
def test200_030_ShouldWorkOnHalfX(self): mySample = SM.Sample(self.nominalN) self.assertAlmostEquals(mySample.gamma(5.0 / 2.0), 1.329, 3)
def test600_060ShouldCalculateHighNLowT2TailEdgeCase(self): mySample = SM.Sample(20) self.assertAlmostEquals(mySample.p(0.2567, 2), 0.200, 3)
def test100_940_ShouldRaiseExceptionOnMissingN(self): expectedString = "Sample.__init__:" with self.assertRaises(ValueError) as context: SM.Sample() self.assertEquals(expectedString, context.exception.args[0][0:len(expectedString)])
def test200_010_ShouldReturnUpperTerminationCondition(self): mySample = SM.Sample(self.nominalN) self.assertEquals(mySample.gamma(1), 1)
def test600_930ShouldRaiseExceptionInvalidTails(self): mySample = SM.Sample(self.nominalN) with self.assertRaises(ValueError) as context: mySample.p(t=self.nominalT, tails=0)
def test600_110ShouldCalculateCalculateWithDefaultTails(self): mySample = SM.Sample(7) self.assertAlmostEquals(mySample.p(1.8946), .950, 3)
def test600_100ShouldCalculateHighHighT2TailEdgeCase(self): mySample = SM.Sample(20) self.assertAlmostEquals(mySample.p(2.8453, 2), .990, 3)
def test600_090ShouldCalculateHighHighT1TailEdgeCase(self): mySample = SM.Sample(20) self.assertAlmostEquals(mySample.p(2.8453, 1), .995, 3)
def test600_080ShouldCalculateLowNHighT2EdgeCase(self): mySample = SM.Sample(3) self.assertAlmostEquals(mySample.p(5.8409, 2), .990, 3)
def test000_003_ShouldIntegrate100(self): s = SM.Sample(self.nominalN) self.assertAlmostEquals( s.integrate(0.0, 1.0, 1.0, lambda x, y: x**100), 1.0 / 101.0)
def test200_020_ShouldReturnLowerTerminationCondition(self): mySample = SM.Sample(self.nominalN) self.assertEquals(mySample.gamma(1.0 / 2.0), math.sqrt(math.pi))
def test100_010_ShouldConstruct(self): self.assertIsInstance(SM.Sample(self.nominalN), SM.Sample) # additional tests are for boundary value coverage self.assertIsInstance(SM.Sample(2), SM.Sample) self.assertIsInstance(SM.Sample(29), SM.Sample)
def test200_030_ShouldWorkOnIntegerX(self): mySample = SM.Sample(self.nominalN) self.assertEquals(mySample.gamma(5), 24)
def test600_010ShouldCalculateNominalCase1Tail(self): mySample = SM.Sample(7) self.assertAlmostEquals(mySample.p(1.8946, 1), .950, 3)
def test600_040ShouldCalculateLowNLowT2TailEdgeCase(self): mySample = SM.Sample(3) self.assertAlmostEquals(mySample.p(0.2767, 2), 0.200, 3)