def test_range_parse(): assert isinstance(Range.parse('bytes=0-99'), Range) assert isinstance(Range.parse('BYTES=0-99'), Range) assert isinstance(Range.parse('bytes = 0-99'), Range) assert isinstance(Range.parse('bytes=0 - 102'), Range) assert Range.parse('bytes=10-5') is None assert Range.parse('bytes 5-10') is None assert Range.parse('words=10-5') is None
def test_range_parse(): assert isinstance(Range.parse("bytes=0-99"), Range) assert isinstance(Range.parse("BYTES=0-99"), Range) assert isinstance(Range.parse("bytes = 0-99"), Range) assert isinstance(Range.parse("bytes=0 - 102"), Range) assert Range.parse("bytes=10-5") is None assert Range.parse("bytes 5-10") is None assert Range.parse("words=10-5") is None
def test_parse_range_values(): from webob.byterange import Range range = Range.parse("bytes=1-500") eq_(range.start, 1) eq_(range.end, 501)
def test_parse_range_type(): from webob.byterange import Range from webob.descriptors import parse_range val = parse_range("bytes=1-500") eq_(type(val), type(Range.parse("bytes=1-500")))
def test_parse_range_values(): from webob.byterange import Range from webob.descriptors import parse_range val = parse_range("bytes=1-500") eq_(val.ranges, Range.parse("bytes=1-500").ranges)
def _parse_range(value): if not value: return None # Might return None too: return Range.parse(value)
def test_parse_range_type(): from webob.byterange import Range from webob.descriptors import parse_range val = parse_range("bytes=1-500") assert type(val) is type(Range.parse("bytes=1-500")) # noqa: E701
def test_parse_range_type(): from webob.byterange import Range from webob.descriptors import parse_range val = parse_range("bytes=1-500") assert type(val) == type(Range.parse("bytes=1-500"))
def test_parse_invalid_units(): range = Range(((0, 100), )) assert_equal(range.parse('words=0-99'), None)
def test_parse_missing_equals_sign(): range = Range(((0, 100), )) assert_equal(range.parse('bytes 0-99'), None)
def test_parse_valid_input(): range = Range(((0, 100), )) assert_equal(range.parse('bytes=0-99').__class__, Range)
def test_not_satisfiable(): range = Range.parse("bytes=-100") assert range.range_for_length(50) is None range = Range.parse("bytes=100-") assert range.range_for_length(50) is None
def test_not_satisfiable(): range = Range.parse('bytes=-100') assert_false(range.satisfiable(50)) range = Range.parse('bytes=100-') assert_false(range.satisfiable(50))
def test_parse_valid_input(): range = Range(((0, 100),)) assert_equal(range.parse("bytes=0-99").__class__, Range)
def test_parse_range_values(): from webob.byterange import Range range = Range.parse("bytes=1-500") assert range.start == 1 assert range.end == 501
def test_parse_missing_equals_sign(): range = Range(((0, 100),)) assert_equal(range.parse("bytes 0-99"), None)
def test_parse_invalid_units(): range = Range(((0, 100),)) assert_equal(range.parse("words=0-99"), None)
def parse_range(value): if not value: return None # Might return None too: return Range.parse(value)