def test_check_percentage_with_string(): with pytest.raises(ValueError): checkargs.check_percentage('test')
def test_check_percentage_one(): value = checkargs.check_percentage(1) assert value, 1
def test_check_percentage_over_one(): with pytest.raises(argparse.ArgumentTypeError) as context: checkargs.check_percentage(1.1) assert '1.1 is an invalid percentage value [0,1]' in str(context)
def test_check_percentage_zero(): value = checkargs.check_percentage(0) assert value == 0
def test_check_percentage_with_string(self): with self.assertRaises(ValueError): checkargs.check_percentage('test')
def test_check_percentage_over_one(self): with self.assertRaises(argparse.ArgumentTypeError) as context: checkargs.check_percentage(1.1) self.assertTrue('1.1 is an invalid percentage value [0,1]' in str(context.exception))
def test_check_percentage_one(self): value = checkargs.check_percentage(1) self.assertEqual(value, 1)
def test_check_percentage_zero(self): value = checkargs.check_percentage(0) self.assertEqual(value, 0)