# Path: httoop/six.py

# 
# Path: httoop/exceptions.py
# class InvalidHeader(Invalid):
# 	u"""error raised when header is invalid"""


import pytest
from httoop import six
from httoop.exceptions import InvalidHeader
#	for invalid in six.iterbytes(INVALID_HEADER_FIELD_NAMES):
#		name = b'foo%sbar' % (six.int2byte(invalid),)
#		request_.headers[name] = 'baz'
#		assert name not in request_.headers
#	for invalid in six.iterbytes(LATIN_CHARS):
#		with pytest.raises(InvalidHeader):
#			name = b'foo%sbar' % (six.int2byte(invalid),)
#			request_.headers[name] = 'baz'


@pytest.mark.parametrize('name', (b'Content-Encoding', b'Transfer-Encoding'))
def test_invalid_codec(name, headers):
	headers.parse(b'%s: foo' % (name,))
	with pytest.raises(InvalidHeader):
		headers.elements(name)


def test_unknown_codec(headers):
	headers.parse(b'Content-Type: foo/bar')
	assert headers.elements('Content-Type')[0].codec is None


def test_unknown_charset(headers):
	headers.parse(b"Foo: bar; filename*=BAR-8''foo.html")
	with pytest.raises(InvalidHeader):
		headers.get_element('foo')


def test_invalid_qvalue_accept(headers):
	headers.parse(b'Accept: foo/bar; q=a')

# Path: httoop/six.py

# 
# Path: httoop/exceptions.py
# class InvalidHeader(Invalid):
# 	u"""error raised when header is invalid"""


# Path: tests/headers/test_invalid_headers.py
import pytest
from httoop import six
from httoop.exceptions import InvalidHeader

#	for invalid in six.iterbytes(INVALID_HEADER_FIELD_NAMES):
#		name = b'foo%sbar' % (six.int2byte(invalid),)
#		request_.headers[name] = 'baz'
#		assert name not in request_.headers
#	for invalid in six.iterbytes(LATIN_CHARS):
#		with pytest.raises(InvalidHeader):
#			name = b'foo%sbar' % (six.int2byte(invalid),)
#			request_.headers[name] = 'baz'


@pytest.mark.parametrize('name', (b'Content-Encoding', b'Transfer-Encoding'))
def test_invalid_codec(name, headers):
	headers.parse(b'%s: foo' % (name,))
	with pytest.raises(InvalidHeader):
		headers.elements(name)


def test_unknown_codec(headers):
	headers.parse(b'Content-Type: foo/bar')
	assert headers.elements('Content-Type')[0].codec is None


def test_unknown_charset(headers):
	headers.parse(b"Foo: bar; filename*=BAR-8''foo.html")
	with pytest.raises(InvalidHeader):
		headers.get_element('foo')


def test_invalid_qvalue_accept(headers):
	headers.parse(b'Accept: foo/bar; q=a')

	with pytest.raises(InvalidHeader) as exc: