def test_positive_invalid_int_values(self): """Test that invalid ints don't get through positive arg check.""" f = cmdargs.Positive(int) for x in [-1, 0]: with self.assertRaises(argparse.ArgumentTypeError): f(x)
def test_positive_invalid_float_values(self): """Test that invalid floats don't get through positive arg check.""" f = cmdargs.Positive(float) for x in [-1.0, -self.EPS, -1e-5, 0.0]: with self.assertRaises(argparse.ArgumentTypeError): f(x)
def test_positive_valid_int_values(self): """Test that valid ints get through positive arg check.""" f = cmdargs.Positive(int) for x in [1, 10, 10000]: self.assertAlmostEqual(x, f(x))
def test_positive_valid_float_values(self): """Test that valid floats get through positive arg check.""" f = cmdargs.Positive(float) for x in [1e-30, self.EPS, 1e-5, 1.0, 1e5, 1e30]: self.assertAlmostEqual(x, f(x))
def test_positive_invalid_int_values(self): f = cmdargs.Positive(int) for x in [-1, 0]: with self.assertRaises(argparse.ArgumentTypeError): f(x)
def test_positive_valid_int_values(self): f = cmdargs.Positive(int) for x in [1, 10, 10000]: self.assertAlmostEqual(x, f(x))
def test_positive_invalid_float_values(self): f = cmdargs.Positive(float) for x in [-1.0, -self.EPS, -1e-5, 0.0]: with self.assertRaises(argparse.ArgumentTypeError): f(x)
def test_positive_valid_float_values(self): f = cmdargs.Positive(float) for x in [1e-30, self.EPS, 1e-5, 1.0, 1e5, 1e30]: self.assertAlmostEqual(x, f(x))