# Path: pgzero/loaders.py
# def set_root(path):
#     def real_path(path):
#     def real_path(path):
# def validate_lowercase(relpath):
# def validate_compatible_path(path):
#     def __init__(self, subpath):
#     def validate_root(self, name):
#     def _root(self):
#     def cache_key(name, args, kwargs):
#     def load(self, name, *args, **kwargs):
#     def __getattr__(self, name):
#     def _load(self, path):
#     def _load(self, path):
#     def _load(self, path, fontsize=None):
# def getfont(
#         fontname=None,
#         fontsize=None,
#         sysfontname=None,
#         bold=None,
#         italic=None,
#         underline=None):
# class InvalidCase(Exception):
# class ResourceLoader:
# class ImageLoader(ResourceLoader):
# class UnsupportedFormat(Exception):
# class SoundLoader(ResourceLoader):
# class FontLoader(ResourceLoader):
#     EXTNS = ['png', 'gif', 'jpg', 'jpeg', 'bmp']
#     TYPE = 'image'
#     EXTNS = ['wav', 'ogg', 'oga']
#     TYPE = 'sound'
#     EXTNS = ['ttf']
#     TYPE = 'font'


import sys
import pygame
from unittest import TestCase, expectedFailure, skipIf
from pgzero.loaders import sounds, set_root, UnsupportedFormat


pygame.init()


class SoundFormatsTest(TestCase):
    """Test that sound formats we cannot open show an appropriate message."""
    @classmethod
    def setUpClass(self):
        set_root(__file__)

    def assert_loadable(self, name):
        s = sounds.load(name)
        l = s.get_length()

        assert 0.85 < l < 1.0, \
            "Failed to correctly load sound (got length %0.1fs)" % l

    def assert_errmsg(self, name, pattern):
        with self.assertRaisesRegex(UnsupportedFormat, pattern):

# Path: pgzero/loaders.py
# def set_root(path):
#     def real_path(path):
#     def real_path(path):
# def validate_lowercase(relpath):
# def validate_compatible_path(path):
#     def __init__(self, subpath):
#     def validate_root(self, name):
#     def _root(self):
#     def cache_key(name, args, kwargs):
#     def load(self, name, *args, **kwargs):
#     def __getattr__(self, name):
#     def _load(self, path):
#     def _load(self, path):
#     def _load(self, path, fontsize=None):
# def getfont(
#         fontname=None,
#         fontsize=None,
#         sysfontname=None,
#         bold=None,
#         italic=None,
#         underline=None):
# class InvalidCase(Exception):
# class ResourceLoader:
# class ImageLoader(ResourceLoader):
# class UnsupportedFormat(Exception):
# class SoundLoader(ResourceLoader):
# class FontLoader(ResourceLoader):
#     EXTNS = ['png', 'gif', 'jpg', 'jpeg', 'bmp']
#     TYPE = 'image'
#     EXTNS = ['wav', 'ogg', 'oga']
#     TYPE = 'sound'
#     EXTNS = ['ttf']
#     TYPE = 'font'


# Path: test/test_sound_formats.py
import sys
import pygame
from unittest import TestCase, expectedFailure, skipIf
from pgzero.loaders import sounds, set_root, UnsupportedFormat


pygame.init()


class SoundFormatsTest(TestCase):
    """Test that sound formats we cannot open show an appropriate message."""
    @classmethod
    def setUpClass(self):
        set_root(__file__)

    def assert_loadable(self, name):
        s = sounds.load(name)
        l = s.get_length()

        assert 0.85 < l < 1.0, \
            "Failed to correctly load sound (got length %0.1fs)" % l

    def assert_errmsg(self, name, pattern):
        with self.assertRaisesRegex(UnsupportedFormat, pattern):

            sounds.load(name)
