<s> from __future__ import absolute_import , print_function , unicode_literals <EOL> import unittest <EOL> from mock import Mock <EOL> import vcstools . vcs_abstraction <EOL> from vcstools . vcs_abstraction import register_vcs , get_registered_vcs_types , get_vcs <EOL> from vcstools import get_vcs_client <EOL> class TestVcsAbstraction ( unittest . TestCase ) : <EOL> def test_register_vcs ( self ) : <EOL> try : <EOL> backup = vcstools . vcs_abstraction . _VCS_TYPES <EOL> vcstools . vcs_abstraction . _VCS_TYPES = { } <EOL> self . assertEqual ( [ ] , get_registered_vcs_types ( ) ) <EOL> mock_class = Mock ( ) <EOL> register_vcs ( '<STR_LIT:foo>' , mock_class ) <EOL> self . assertEqual ( [ '<STR_LIT:foo>' ] , get_registered_vcs_types ( ) ) <EOL> finally : <EOL> vcstools . vcs_abstraction . _VCS_TYPES = backup <EOL> def test_get_vcs ( self ) : <EOL> try : <EOL> backup = vcstools . vcs_abstraction . _VCS_TYPES <EOL> vcstools . vcs_abstraction . _VCS_TYPES = { } <EOL> self . assertEqual ( [ ] , get_registered_vcs_types ( ) ) <EOL> mock_class = Mock ( ) <EOL> register_vcs ( '<STR_LIT:foo>' , mock_class ) <EOL> self . assertEqual ( mock_class , get_vcs ( '<STR_LIT:foo>' ) ) <EOL> self . assertRaises ( ValueError , get_vcs , '<STR_LIT:bar>' ) <EOL> finally : <EOL> vcstools . vcs_abstraction . _VCS_TYPES = backup <EOL> def test_get_vcs_client ( self ) : <EOL> try : <EOL> backup = vcstools . vcs_abstraction . _VCS_TYPES <EOL> vcstools . vcs_abstraction . _VCS_TYPES = { } <EOL> self . assertEqual ( [ ] , get_registered_vcs_types ( ) ) <EOL> mock_class = Mock ( ) <EOL> mock_instance = Mock ( ) <EOL> mock_class . return_value = mock_instance <EOL> register_vcs ( '<STR_LIT:foo>' , mock_class ) <EOL> self . assertEqual ( mock_instance , get_vcs_client ( '<STR_LIT:foo>' , '<STR_LIT>' ) ) <EOL> self . assertRaises ( ValueError , get_vcs_client , '<STR_LIT:bar>' , '<STR_LIT>' ) <EOL> finally : <EOL> vcstools . vcs_abstraction . _VCS_TYPES = backup </s>
