# Path: viceroy/exceptions.py
# class ResultNotFound(ViceroyException):
#     pass
# 
# Path: viceroy/exceptions.py
# class JavascriptError(ViceroyException):
#     pass


import contextlib
import os
import unittest
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from .exceptions import ResultNotFound
from .exceptions import JavascriptError
    def setUpClass(cls):
        super(ViceroyTestCase, cls).setUpClass()
        cls.viceroy_cache = cls.viceroy_get_results()

    @classmethod
    def tearDownClass(cls):
        if hasattr(cls, 'viceroy_cache'):
            del cls.viceroy_cache
        super(ViceroyTestCase, cls).tearDownClass()


def test_method_proxy(full_name, short_name):
    def test_method(self):
        result = self.viceroy_cache.get(short_name, None)
        if result is None:
            result = self.viceroy_cache.get('viceroy_javascript_error', None)
            if result is None:
                keys = self.viceroy_cache.keys()
                raise ResultNotFound(
                    'Result for {!r} not found. Available results: {}'.format(
                        short_name, ', '.join(
                            '{!r}'.format(key) for key in keys
                        )
                    )
                )
        if result['code'] == '.':
            return
        elif result['code'] == 'F':
            self.fail(result['message'])
        elif result['code'] == 'E':

# Path: viceroy/exceptions.py
# class ResultNotFound(ViceroyException):
#     pass
# 
# Path: viceroy/exceptions.py
# class JavascriptError(ViceroyException):
#     pass


# Path: viceroy/api.py
import contextlib
import os
import unittest
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from .exceptions import ResultNotFound
from .exceptions import JavascriptError

    def setUpClass(cls):
        super(ViceroyTestCase, cls).setUpClass()
        cls.viceroy_cache = cls.viceroy_get_results()

    @classmethod
    def tearDownClass(cls):
        if hasattr(cls, 'viceroy_cache'):
            del cls.viceroy_cache
        super(ViceroyTestCase, cls).tearDownClass()


def test_method_proxy(full_name, short_name):
    def test_method(self):
        result = self.viceroy_cache.get(short_name, None)
        if result is None:
            result = self.viceroy_cache.get('viceroy_javascript_error', None)
            if result is None:
                keys = self.viceroy_cache.keys()
                raise ResultNotFound(
                    'Result for {!r} not found. Available results: {}'.format(
                        short_name, ', '.join(
                            '{!r}'.format(key) for key in keys
                        )
                    )
                )
        if result['code'] == '.':
            return
        elif result['code'] == 'F':
            self.fail(result['message'])
        elif result['code'] == 'E':

            raise JavascriptError(result['message'])