コード例 #1
0
ファイル: test_cleanups.py プロジェクト: Guy-Lev/slash
def test_add_test_cleanup_from_session_scope_forbidden(checkpoint):

    with slash.Session():
        with pytest.raises(IncorrectScope):
            slash.add_cleanup(checkpoint, scope='test')

    assert not checkpoint.called
コード例 #2
0
def test_add_test_cleanup_from_session_scope_forbidden(checkpoint):

    with slash.Session():
        with pytest.raises(IncorrectScope):
            slash.add_cleanup(checkpoint, scope='test')

    assert not checkpoint.called
コード例 #3
0
ファイル: test_hook_calling.py プロジェクト: Guy-Lev/slash
    def __code__(): # pylint: disable=unused-variable
        import gossip # pylint: disable=reimported
        # pylint: disable=undefined-variable,unused-variable
        def session_cleanup_callback():
            __ut__.events.add('session_cleanup')
        slash.add_cleanup(session_cleanup_callback, scope='session')

        @gossip.register('slash.test_end')
        def test_end_callback():
            __ut__.events.add('test_end')
コード例 #4
0
    def __code__(): # pylint: disable=unused-variable
        import gossip # pylint: disable=redefined-outer-name,reimported
        # pylint: disable=undefined-variable,unused-variable
        def session_cleanup_callback():
            __ut__.events.add('session_cleanup')
        slash.add_cleanup(session_cleanup_callback, scope='session')

        @gossip.register('slash.test_end')
        def test_end_callback():
            __ut__.events.add('test_end')
コード例 #5
0
ファイル: test_scoped_cleanups.py プロジェクト: hagai26/slash
def test_test_scoped_cleanups_in_session(checkpoint):
    # with scoped cleanups, and the default being 'test', there is a special meaning
    # for cleanups registered outside of tests....
    with slash.Session() as s:
        slash.add_cleanup(checkpoint)
        assert not checkpoint.called
        with s.get_started_context():
            pass

        assert not checkpoint.called
    assert checkpoint.called
コード例 #6
0
ファイル: fixtures.py プロジェクト: eliadl/python-butler
def butler_client():
    butler_server = ButlerTest.Server('http://localhost:8888')
    butler_client = ButlerTest.Client('http://localhost:8888')
    butler_server.run_async()
    time.sleep(0.3)

    def stop_server():
        butler_client.get_stop()
        time.sleep(0.3)

    slash.add_cleanup(stop_server, scope='session')
    return butler_client
コード例 #7
0
def test_cleanups_within_cleanups_preserve_scope(checkpoint1):
    """Cleanups added from within other cleanups should happen within the scope of the parent cleanups
    """
    @slash.parametrize('x', [1, 2])
    def test_something(x):
        pass

    with slash.Session() as s:
        [fake_test1, fake_test2] = Loader().get_runnables(test_something)  # pylint: disable=unbalanced-tuple-unpacking

        s.scope_manager.begin_test(fake_test1)

        def cleanup():
            slash.add_cleanup(checkpoint1)

        slash.add_cleanup(cleanup)

        assert not checkpoint1.called
        s.scope_manager.end_test(fake_test1)

        assert checkpoint1.called
コード例 #8
0
ファイル: test_scoped_cleanups.py プロジェクト: Guy-Lev/slash
def test_cleanups_within_cleanups_preserve_scope(checkpoint1):
    """Cleanups added from within other cleanups should happen within the scope of the parent cleanups
    """

    @slash.parametrize('x', [1, 2])
    def test_something(x): # pylint: disable=unused-argument
        pass

    with slash.Session() as s:
        [fake_test1, fake_test2] = Loader().get_runnables(test_something) # pylint: disable=unbalanced-tuple-unpacking

        s.scope_manager.begin_test(fake_test1)

        def cleanup():
            slash.add_cleanup(checkpoint1)

        slash.add_cleanup(cleanup)

        assert not checkpoint1.called
        s.scope_manager.end_test(fake_test1)

        assert checkpoint1.called
コード例 #9
0
        def test_something():

            assert not slash.is_in_cleanup()
            assert slash.get_current_cleanup_phase() is None

            def session_cleanup():
                assert slash.is_in_cleanup()
                assert slash.get_current_cleanup_phase() == 'session'

            slash.add_cleanup(session_cleanup, scope='session')

            def module_cleanup():
                assert slash.is_in_cleanup()
                assert slash.get_current_cleanup_phase() == 'module'

            slash.add_cleanup(module_cleanup, scope='module')

            def regular_cleanup():
                assert slash.is_in_cleanup()
                assert slash.get_current_cleanup_phase() == 'test'

            slash.add_cleanup(regular_cleanup)
コード例 #10
0
 def test1(self_):
     self.events.test1()
     slash.add_cleanup(self.events.cleanup, "test1 cleanup 2")
     slash.add_cleanup(self.events.cleanup, "test1 cleanup 1")
コード例 #11
0
    def __code__():
        def callback():
            __ut__.events.add('success_only_cleanup_called')  # pylint: disable=undefined-variable

        slash.add_cleanup(callback, success_only=True)
        slash.skip_test()
コード例 #12
0
 def test_end():
     slash.add_cleanup(checkpoint, scope='session')
コード例 #13
0
 def test_something():
     slash.add_cleanup(cleanup)
コード例 #14
0
 def cleanup():
     slash.add_cleanup(checkpoint1)
コード例 #15
0
ファイル: test_cleanups.py プロジェクト: rechtere/slash
 def test(self_):
     slash.add_cleanup(self.events.cleanup, 1)
     slash.add_cleanup(self.events.cleanup, 2)
     raise Exception("!!!")
コード例 #16
0
ファイル: test_result.py プロジェクト: guytish/slash
    def __code__():  # pylint: disable=unused-variable
        def cleanup():
            slash.context.result.data['ok'] = True

        slash.add_cleanup(cleanup, scope='session')
コード例 #17
0
def test_1():
    result = slash.context.result
    def cleanup():
        result.add_error('this is a deferred error from test_1')
    slash.add_cleanup(cleanup, scope='module')
コード例 #18
0
ファイル: test_cleanups.py プロジェクト: Guy-Lev/slash
 def __code__():
     def callback():
         __ut__.events.add('success_only_cleanup_called') # pylint: disable=undefined-variable
     slash.add_cleanup(callback, success_only=True)
     slash.skip_test()
コード例 #19
0
ファイル: test_cleanups.py プロジェクト: Guy-Lev/slash
 def test_end():
     slash.add_cleanup(checkpoint, scope='session')
コード例 #20
0
ファイル: test_cleanups.py プロジェクト: Guy-Lev/slash
    def test_end():

        with pytest.raises(CannotAddCleanup):
            slash.add_cleanup(checkpoint)
コード例 #21
0
 def test(self_):
     slash.add_cleanup(self.events.cleanup, 1)
     slash.add_cleanup(self.events.cleanup, 2)
     raise Exception("!!!")
コード例 #22
0
 def _do_test_callback(self, _):
     slash.add_cleanup(self._regular_cleanup)
     slash.add_critical_cleanup(self._critical_cleanup)
     raise KeyboardInterrupt()
コード例 #23
0
ファイル: test_cleanups.py プロジェクト: rechtere/slash
 def test2(self_):
     self.events.test2()
     slash.add_cleanup(self.events.cleanup, "test2 cleanup")
コード例 #24
0
def test_cleanup_args_kwargs_deprecated():
    with slash.Session() as s:
        slash.add_cleanup(lambda: None, "arg1", arg2=1)
    [w] = s.warnings
    assert 'deprecated' in str(w).lower()
コード例 #25
0
ファイル: test_cleanups.py プロジェクト: rechtere/slash
 def test1(self_):
     self.events.test1()
     slash.add_cleanup(self.events.cleanup, "test1 cleanup 2")
     slash.add_cleanup(self.events.cleanup, "test1 cleanup 1")
コード例 #26
0
ファイル: test_scoped_cleanups.py プロジェクト: kostyll/slash
def test_cleanups_before_session_start_get_deferred(checkpoint):
    with slash.Session() as s:
        slash.add_cleanup(checkpoint)
        with s.get_started_context():
            assert not checkpoint.called
        assert checkpoint.called_count == 1
コード例 #27
0
 def test2(self_):
     self.events.test2()
     slash.add_cleanup(self.events.cleanup, "test2 cleanup")
コード例 #28
0
 def session_start():
     slash.add_cleanup(events.append, args=(('session_cleanup', 1), ))
     slash.add_cleanup(events.append, args=(('session_cleanup', 2), ))
コード例 #29
0
ファイル: test_scoped_cleanups.py プロジェクト: kostyll/slash
def test_cleanups_without_session_start_never_called(checkpoint):
    assert not checkpoint.called
    with slash.Session():
        slash.add_cleanup(checkpoint)
        assert not checkpoint.called
    assert not checkpoint.called
コード例 #30
0
ファイル: test_cleanups.py プロジェクト: E8-Storage/slash
def test_cleanup_args_kwargs_deprecated():
    with slash.Session() as s:
        slash.add_cleanup(lambda: None, "arg1", arg2=1)
    [w] = s.warnings
    assert 'deprecated' in str(w).lower()
コード例 #31
0
def test_cannot_add_cleanup_without_active_session():
    with pytest.raises(RuntimeError):
        slash.add_cleanup(lambda: None)
コード例 #32
0
ファイル: test_cleanups.py プロジェクト: E8-Storage/slash
 def __code__():
     def callback():
         __ut__.events.add('success_only_cleanup_called')
     slash.add_cleanup(callback, success_only=True)
     slash.skip_test()
コード例 #33
0
    def test_end():

        with pytest.raises(CannotAddCleanup):
            slash.add_cleanup(checkpoint)
コード例 #34
0
ファイル: test_cleanups.py プロジェクト: E8-Storage/slash
def test_cannot_add_cleanup_without_active_session():
    with pytest.raises(RuntimeError):
        slash.add_cleanup(lambda: None)
コード例 #35
0
    def __code__():
        def cleanup():
            slash.context.result.data['fixture_called'] = True

        slash.add_cleanup(cleanup, scope='test')
コード例 #36
0
ファイル: test_interruptions.py プロジェクト: rechtere/slash
 def _do_test_callback(self, _):
     slash.add_cleanup(self._regular_cleanup)
     slash.add_critical_cleanup(self._critical_cleanup)
     raise KeyboardInterrupt()
コード例 #37
0
 def test_partial_cleanup():
     slash.add_cleanup(functools.partial(cleanup_with_argument, 5))
コード例 #38
0
def test_cleanups_without_session_start_never_called(checkpoint):
    assert not checkpoint.called
    with slash.Session():
        slash.add_cleanup(checkpoint)
        assert not checkpoint.called
    assert not checkpoint.called
コード例 #39
0
ファイル: test_hook_calling.py プロジェクト: hagai26/slash
 def test_something():
     slash.add_cleanup(cleanup)
コード例 #40
0
def test_cleanups_before_session_start_get_deferred(checkpoint):
    with slash.Session() as s:
        slash.add_cleanup(checkpoint)
        with s.get_started_context():
            assert not checkpoint.called
        assert checkpoint.called_count == 1