コード例 #1
0
def test_get_instance_returns_configured_tchannel():

    TChannel.reset()
    TChannel.prepare('my-app')

    tchannel = TChannel.get_instance()

    assert isinstance(tchannel, AsyncTChannel)
    assert tchannel.name == 'my-app'
コード例 #2
0
def test_get_instance_returns_configured_tchannel():

    TChannel.reset()
    TChannel.prepare('my-app')

    tchannel = TChannel.get_instance()

    assert isinstance(tchannel, AsyncTChannel)
    assert tchannel.name == 'my-app'
コード例 #3
0
def test_stored_seperately_from_async_singleton():

    TChannel.reset()
    AsyncSingleton.reset()

    AsyncSingleton.prepare('async-app')

    with pytest.raises(SingletonNotPreparedError):
        TChannel.get_instance()

    TChannel.prepare('sync-app')

    instance = TChannel.get_instance()

    assert isinstance(instance,  SyncTChannel)
    assert AsyncSingleton.get_instance() is not instance
コード例 #4
0
def test_stored_seperately_from_async_singleton():

    TChannel.reset()
    AsyncSingleton.reset()

    AsyncSingleton.prepare('async-app')

    with pytest.raises(SingletonNotPreparedError):
        TChannel.get_instance()

    TChannel.prepare('sync-app')

    instance = TChannel.get_instance()

    assert isinstance(instance,  SyncTChannel)
    assert AsyncSingleton.get_instance() is not instance
コード例 #5
0
def test_must_call_prepare_before_get_instance():

    TChannel.reset()

    with pytest.raises(SingletonNotPreparedError):
        TChannel.get_instance()
コード例 #6
0
def test_get_instance_is_singleton():

    TChannel.reset()
    TChannel.prepare('my-app')

    assert TChannel.get_instance() is TChannel.get_instance()
コード例 #7
0
def test_must_call_prepare_before_get_instance():

    TChannel.reset()

    with pytest.raises(SingletonNotPreparedError):
        TChannel.get_instance()
コード例 #8
0
def test_get_instance_is_singleton():

    TChannel.reset()
    TChannel.prepare('my-app')

    assert TChannel.get_instance() is TChannel.get_instance()