Exemplo n.º 1
0
    def test_restores_original_value(self):
        original_value = doubles.testing.User
        patch_class('doubles.testing.User')

        teardown()

        assert original_value == doubles.testing.User
Exemplo n.º 2
0
    def test_restores_original_value(self):
        original_value = doubles.testing.User
        patch_class('doubles.testing.User')

        teardown()

        assert original_value == doubles.testing.User
Exemplo n.º 3
0
    def test_using_the_patched_class(self):
        allow_constructor(patch_class('doubles.testing.User')).and_return('result_1')
        allow_constructor(patch_class('doubles.testing.OldStyleUser')).and_return('result_2')

        result_1, result_2 = doubles.testing.top_level_function_that_creates_an_instance()

        assert result_1 == 'result_1'
        assert result_2 == 'result_2'
Exemplo n.º 4
0
    def test_using_the_patched_class(self):
        allow_constructor(
            patch_class('doubles.testing.User')).and_return('result_1')
        allow_constructor(
            patch_class('doubles.testing.OldStyleUser')).and_return('result_2')

        result_1, result_2 = doubles.testing.top_level_function_that_creates_an_instance(
        )

        assert result_1 == 'result_1'
        assert result_2 == 'result_2'
Exemplo n.º 5
0
def gen_mock_service():
    class_name = 'bootcamp.handlers.add_user.UserService'
    mock_service = UserService()
    service_class = patch_class(class_name)
    allow_constructor(service_class).and_return(mock_service)
    return mock_service
Exemplo n.º 6
0
def gen_mock_service():
    class_name = 'bootcamp.handlers.title.TitleService'
    mock_service = TitleService()
    service_class = patch_class(class_name)
    allow_constructor(service_class).and_return(mock_service)
    return mock_service
Exemplo n.º 7
0
 def test_class_double_after_patching(self):
     patch_class('doubles.testing.User')
     assert ClassDouble('doubles.testing.User')
Exemplo n.º 8
0
 def test_non_existent_class(self):
     with pytest.raises(VerifyingDoubleImportError):
         patch_class('doubles.testing.NotReal')
Exemplo n.º 9
0
 def test_raises_an_error_trying_to_patch_a_function(self):
     with pytest.raises(VerifyingDoubleImportError):
         patch_class('doubles.test.top_level_function')
Exemplo n.º 10
0
 def test_class_double_after_patching(self):
     patch_class('doubles.testing.User')
     assert ClassDouble('doubles.testing.User')
Exemplo n.º 11
0
 def test_non_existent_class(self):
     with pytest.raises(VerifyingDoubleImportError):
         patch_class('doubles.testing.NotReal')
Exemplo n.º 12
0
 def test_raises_an_error_trying_to_patch_a_function(self):
     with pytest.raises(VerifyingDoubleImportError):
         patch_class('doubles.test.top_level_function')