def test_specs__path_is_displayed_in_exception(): def _path_is_displayed_in_exception(spec, value): assert_raises_regexp(MakefileError, _DUMMY_PATH_STR, spec, _DUMMY_PATH, value) yield _path_is_displayed_in_exception, IsInt(), "foo" yield _path_is_displayed_in_exception, IsUnsignedInt(), -1 yield _path_is_displayed_in_exception, IsFloat(), "abc" yield _path_is_displayed_in_exception, IsBoolean(), 1 yield _path_is_displayed_in_exception, IsStr(), 1 yield _path_is_displayed_in_exception, IsNone(), 1 yield _path_is_displayed_in_exception, ValueLT(0), 1 yield _path_is_displayed_in_exception, ValueLE(0), 1 yield _path_is_displayed_in_exception, ValueGE(0), -1 yield _path_is_displayed_in_exception, ValueGT(0), -1 yield _path_is_displayed_in_exception, ValueIn([1]), 2 yield _path_is_displayed_in_exception, ValuesIntersect([1]), [2] yield _path_is_displayed_in_exception, ValuesSubsetOf([1]), [2] yield _path_is_displayed_in_exception, ValueMissing(), True yield _path_is_displayed_in_exception, And(IsStr), 1 yield _path_is_displayed_in_exception, Or(IsStr), 1 yield _path_is_displayed_in_exception, Xor(IsStr, IsInt), True yield _path_is_displayed_in_exception, Not(IsInt), 1 yield _path_is_displayed_in_exception, StringIn("abc"), 1 yield _path_is_displayed_in_exception, StringsIntersect("abc"), [1] yield _path_is_displayed_in_exception, StringsSubsetOf("abc"), [1] yield _path_is_displayed_in_exception, StringIsUppercase(), 1 yield _path_is_displayed_in_exception, StringStartsWith("FOO"), 1 yield _path_is_displayed_in_exception, StringEndsWith("FOO"), 1 yield _path_is_displayed_in_exception, IsListOf(IsInt), "foo" yield _path_is_displayed_in_exception, IsDictOf(IsInt, IsInt), 1
def test_xor__default_set__valid_value(): spec = Xor(IsInt, ValueGT(10), default=5) assert_equal(spec.default, 5)
def test_xor__default_not_set(): spec = Xor(IsInt, ValueGT(10)) assert_is(spec.default, DEFAULT_NOT_SET)
def test_or__default_set__valid_value(): spec = Or(IsInt, ValueGT(10), default=17) assert_equal(spec.default, 17)
def test_and__default_set__must_meet_spec(): assert_raises(ValueError, And, IsInt, ValueGT(10), default=5)
def test_and__default_set__valid_value(): spec = And(IsInt, ValueGT(10), default=20) assert_equal(spec.default, 20)
def test_and__default_not_set(): spec = And(IsInt, ValueGT(10)) assert_is(spec.default, DEFAULT_NOT_SET)
def test_value_gt__rejects_value_eq(): spec = ValueGT(7) assert_raises(MakefileError, spec, _DUMMY_PATH, 7)
def test_is_value_gt__default_not_set(): spec = ValueGT(10) assert_is(spec.default, DEFAULT_NOT_SET)
def test_value_gt__custom_description(): spec = ValueGT('Bar', description='more than {rvalue}') assert_equal(spec.description, "more than 'Bar'")
def test_value_gt__default_description(): spec = ValueGT('Foo') assert_equal(spec.description, "value > 'Foo'")
def test_value_gt__accepts_value_gt__with_key(): spec = ValueGT(7, key=len) spec(_DUMMY_PATH, "abcdefgh")
def test_value_gt__accepts_value_eq__with_key(): spec = ValueGT(7, key=len) assert_raises(MakefileError, spec, _DUMMY_PATH, "abcdefg")
def test_value_gt__accepts_value_gt(): spec = ValueGT(7) spec(_DUMMY_PATH, 8)
def test_xor__default_set__must_meet_spec(): assert_raises(ValueError, Xor, IsInt, ValueGT(10), default=17)
def test_xor__defaults_not_set_in_specs(): assert_raises(ValueError, Xor, IsInt(default=10), ValueGT(10))
def test_is_value_gt__default_set__valid_value(): spec = ValueGT(10, default=11) assert_equal(spec.default, 11)