# Path: gears/environment.py
# class Compilers(dict):
#     """The registry for compilers. It acts like a dict with extensions as keys
#     and compilers as values. Every registered extension can have only one
#     compiler.
#     """
# 
#     def register(self, extension, compiler):
#         """Register passed `compiler` with passed `extension`."""
#         self[extension] = compiler
# 
#     def unregister(self, extension):
#         """Remove registered compiler for passed `extension`. If compiler for
#         this extension does not found in the registry, nothing happens.
#         """
#         if extension in self:
#             del self[extension]


from gears.environment import Compilers
from mock import Mock
from unittest2 import TestCase



class CompilersTests(TestCase):

    def setUp(self):
        self.compilers = Compilers()
        self.first_compiler = Mock()
        self.second_compiler = Mock()

    def test_register(self):
        self.compilers.register('.css', self.first_compiler)
        self.assertIn('.css', self.compilers)
        self.assertIs(self.compilers['.css'], self.first_compiler)

    def test_register_twice(self):
        self.compilers.register('.css', self.first_compiler)

# Path: gears/environment.py
# class Compilers(dict):
#     """The registry for compilers. It acts like a dict with extensions as keys
#     and compilers as values. Every registered extension can have only one
#     compiler.
#     """
# 
#     def register(self, extension, compiler):
#         """Register passed `compiler` with passed `extension`."""
#         self[extension] = compiler
# 
#     def unregister(self, extension):
#         """Remove registered compiler for passed `extension`. If compiler for
#         this extension does not found in the registry, nothing happens.
#         """
#         if extension in self:
#             del self[extension]


# Path: tests/test_environment_engines.py
from gears.environment import Compilers
from mock import Mock
from unittest2 import TestCase




class CompilersTests(TestCase):

    def setUp(self):
        self.compilers = Compilers()
        self.first_compiler = Mock()
        self.second_compiler = Mock()

    def test_register(self):
        self.compilers.register('.css', self.first_compiler)
        self.assertIn('.css', self.compilers)
        self.assertIs(self.compilers['.css'], self.first_compiler)

    def test_register_twice(self):
        self.compilers.register('.css', self.first_compiler)

        self.compilers.register('.css', self.second_compiler)