# Path: webdriverwrapper/decorators.py

# 
# Path: webdriverwrapper/exceptions.py
# class ErrorPageException(WebdriverWrapperException):
#     """
#     Exception raised when there is some unexpected error page. Like page 404,
#     500 and so on.
#     """
# 
#     def __init__(self, url, error_page, expected_error_page, allowed_error_pages, traceback=None):
#         if expected_error_page:
#             msg = 'Expected error page "{}", but found "{}" instead.'.format(expected_error_page, error_page)
#         else:
#             msg = 'Unexpected error page "{}".'.format(error_page)
#         if allowed_error_pages:
#             msg += ' Allowed error pages: "{}"'.format(allowed_error_pages)
#         if traceback:
#             msg += '\n\nTraceback:\n{}'.format(traceback)
#         super(ErrorPageException, self).__init__(url, msg)
# 
# class ErrorMessagesException(WebdriverWrapperException):
#     """
#     Exception raised when there is some unexpected error message. Like "some
#     field is mandatory", "wrong e-mail" and so on.
#     """
# 
#     def __init__(self, url, error_messages, expected_error_messages, allowed_error_messages):
#         if expected_error_messages:
#             msg = 'Expected error messages "{}", but found "{}" instead.'.format(expected_error_messages, error_messages)
#         else:
#             msg = 'Unexpected error messages "{}".'.format(error_messages)
#         if allowed_error_messages:
#             msg += ' Allowed error messages: "{}"'.format(allowed_error_messages)
#         super(ErrorMessagesException, self).__init__(url, msg)


import pytest
from webdriverwrapper.decorators import allowed_error_pages, allowed_any_error_message
from webdriverwrapper.exceptions import ErrorPageException, ErrorMessagesException



@allowed_error_pages('403')
def test_check_error_page(driver_error_page):
    with pytest.raises(ErrorPageException) as excinfo:
        driver_error_page.check_errors()


@allowed_error_pages('403')
def test_check_errors_expected_error_page(driver_error_page):
    driver_error_page.check_errors(expected_error_page='403')


@allowed_error_pages('403')
def test_check_errors_allowed_error_pages(driver_error_page):
    driver_error_page.check_errors(allowed_error_pages=('403',))



# Path: webdriverwrapper/decorators.py

# 
# Path: webdriverwrapper/exceptions.py
# class ErrorPageException(WebdriverWrapperException):
#     """
#     Exception raised when there is some unexpected error page. Like page 404,
#     500 and so on.
#     """
# 
#     def __init__(self, url, error_page, expected_error_page, allowed_error_pages, traceback=None):
#         if expected_error_page:
#             msg = 'Expected error page "{}", but found "{}" instead.'.format(expected_error_page, error_page)
#         else:
#             msg = 'Unexpected error page "{}".'.format(error_page)
#         if allowed_error_pages:
#             msg += ' Allowed error pages: "{}"'.format(allowed_error_pages)
#         if traceback:
#             msg += '\n\nTraceback:\n{}'.format(traceback)
#         super(ErrorPageException, self).__init__(url, msg)
# 
# class ErrorMessagesException(WebdriverWrapperException):
#     """
#     Exception raised when there is some unexpected error message. Like "some
#     field is mandatory", "wrong e-mail" and so on.
#     """
# 
#     def __init__(self, url, error_messages, expected_error_messages, allowed_error_messages):
#         if expected_error_messages:
#             msg = 'Expected error messages "{}", but found "{}" instead.'.format(expected_error_messages, error_messages)
#         else:
#             msg = 'Unexpected error messages "{}".'.format(error_messages)
#         if allowed_error_messages:
#             msg += ' Allowed error messages: "{}"'.format(allowed_error_messages)
#         super(ErrorMessagesException, self).__init__(url, msg)


# Path: tests/test_errors.py
import pytest
from webdriverwrapper.decorators import allowed_error_pages, allowed_any_error_message
from webdriverwrapper.exceptions import ErrorPageException, ErrorMessagesException




@allowed_error_pages('403')
def test_check_error_page(driver_error_page):
    with pytest.raises(ErrorPageException) as excinfo:
        driver_error_page.check_errors()


@allowed_error_pages('403')
def test_check_errors_expected_error_page(driver_error_page):
    driver_error_page.check_errors(expected_error_page='403')


@allowed_error_pages('403')
def test_check_errors_allowed_error_pages(driver_error_page):
    driver_error_page.check_errors(allowed_error_pages=('403',))



@allowed_any_error_message