Exemplo n.º 1
0
 def test_nonnegative_invalid_float_values(self):
     """Test that invalid floats don't get through non-negative arg
     check."""
     f = cmdargs.NonNegative(float)
     for x in [-1.0, -self.EPS, -1e-5]:
         with self.assertRaises(argparse.ArgumentTypeError):
             f(x)
Exemplo n.º 2
0
 def test_nonegative_invalid_int_values(self):
     """Test that invalid ints don't get through non-negative arg check."""
     f = cmdargs.NonNegative(int)
     for x in [-1, -10]:
         with self.assertRaises(argparse.ArgumentTypeError):
             f(x)
Exemplo n.º 3
0
 def test_nonegative_valid_int_values(self):
     """Test that valid ints get through non-negative arg check."""
     f = cmdargs.NonNegative(int)
     for x in [0, 1, 10, 10000]:
         self.assertAlmostEqual(x, f(x))
Exemplo n.º 4
0
 def test_nonnegative_valid_float_values(self):
     """Test that valid floats get through non-negative arg check."""
     f = cmdargs.NonNegative(float)
     for x in [1e-30, self.EPS, 1e-5, 0.0, 1.0, 1e5, 1e30]:
         self.assertAlmostEqual(x, f(x))
Exemplo n.º 5
0
 def test_nonegative_invalid_int_values(self):
     f = cmdargs.NonNegative(int)
     for x in [-1, -10]:
         with self.assertRaises(argparse.ArgumentTypeError):
             f(x)
Exemplo n.º 6
0
 def test_nonegative_valid_int_values(self):
     f = cmdargs.NonNegative(int)
     for x in [0, 1, 10, 10000]:
         self.assertAlmostEqual(x, f(x))
Exemplo n.º 7
0
 def test_nonnegative_invalid_float_values(self):
     f = cmdargs.NonNegative(float)
     for x in [-1.0, -self.EPS, -1e-5]:
         with self.assertRaises(argparse.ArgumentTypeError):
             f(x)
Exemplo n.º 8
0
 def test_nonnegative_valid_float_values(self):
     f = cmdargs.NonNegative(float)
     for x in [1e-30, self.EPS, 1e-5, 0.0, 1.0, 1e5, 1e30]:
         self.assertAlmostEqual(x, f(x))