def test_scalar_coerce(): assert scalar_coerce('int', 1) == 1 assert scalar_coerce('int', '1') == 1 assert scalar_coerce('{x: int}', '1') == 1 with raises(TypeError): scalar_coerce('{x: int, y: int}', '1') assert scalar_coerce('date', 'Jan 1st, 2012') == date(2012, 1, 1) assert (scalar_coerce('datetime', 'Jan 1st, 2012 12:00:00') == datetime(2012, 1, 1, 12, 0, 0)) with raises(ValueError): scalar_coerce('date', 'Jan 1st, 2012 12:00:00') assert scalar_coerce('?date', 'Jan 1st, 2012') == date(2012, 1, 1) assert scalar_coerce('?date', '2012-12-01') == date(2012, 12, 1) assert scalar_coerce('?date', '') == None assert scalar_coerce('?int', 0) == 0 assert scalar_coerce('?int', '0') == 0 x = symbol('x', '?int') assert scalar_coerce('?int', x) is x
def test_scalar_coerce(): assert scalar_coerce('int', 1) == 1 assert scalar_coerce('int', '1') == 1 assert scalar_coerce('{x: int}', '1') == 1 with raises(TypeError): scalar_coerce('{x: int, y: int}', '1') assert scalar_coerce('date', 'Jan 1st, 2012') == date(2012, 1, 1) assert (scalar_coerce('datetime', 'Jan 1st, 2012 12:00:00') == datetime( 2012, 1, 1, 12, 0, 0)) with raises(ValueError): scalar_coerce('date', 'Jan 1st, 2012 12:00:00') assert scalar_coerce('?date', 'Jan 1st, 2012') == date(2012, 1, 1) assert scalar_coerce('?date', '2012-12-01') == date(2012, 12, 1) assert scalar_coerce('?date', '') == None assert scalar_coerce('?int', 0) == 0 assert scalar_coerce('?int', '0') == 0
def test_scalar_coerce(): assert scalar_coerce("int", 1) == 1 assert scalar_coerce("int", "1") == 1 assert scalar_coerce("{x: int}", "1") == 1 with pytest.raises(TypeError): scalar_coerce("{x: int, y: int}", "1") assert scalar_coerce("date", "Jan 1st, 2012") == date(2012, 1, 1) assert scalar_coerce("datetime", "Jan 1st, 2012 12:00:00") == datetime(2012, 1, 1, 12, 0, 0) with pytest.raises(TypeError): scalar_coerce("date", "Jan 1st, 2012 12:00:00") assert scalar_coerce("?date", "Jan 1st, 2012") == date(2012, 1, 1) assert scalar_coerce("?date", "2012-12-01") == date(2012, 12, 1) with pytest.raises(TypeError): scalar_coerce("?date", "") assert scalar_coerce("?int", 0) == 0 assert scalar_coerce("?int", "0") == 0 x = symbol("x", "?int") assert scalar_coerce("?int", x) is x
def test_scalar_coerce(): assert scalar_coerce('int', 1) == 1 assert scalar_coerce('int', '1') == 1 assert scalar_coerce('{x: int}', '1') == 1 with pytest.raises(TypeError): scalar_coerce('{x: int, y: int}', '1') assert scalar_coerce('date', 'Jan 1st, 2012') == date(2012, 1, 1) assert (scalar_coerce('datetime', 'Jan 1st, 2012 12:00:00') == datetime( 2012, 1, 1, 12, 0, 0)) with pytest.raises(TypeError): scalar_coerce('date', 'Jan 1st, 2012 12:00:00') assert scalar_coerce('?date', 'Jan 1st, 2012') == date(2012, 1, 1) assert scalar_coerce('?date', '2012-12-01') == date(2012, 12, 1) with pytest.raises(TypeError): scalar_coerce('?date', '') assert scalar_coerce('?int', 0) == 0 assert scalar_coerce('?int', '0') == 0 x = symbol('x', '?int') assert scalar_coerce('?int', x) is x