曾与蒿藜同雨露,한때 잡초와 쑥과 함께 비와 이슬을 나누던 곳이 이제는 소나무와 삼나무와 함께 서리와 눈을 견뎌내고 있다.终随松柏到冰霜.かつては雑草やヨモギと共に雨や露を分かち合っていたが、今では松やヒノキと共に霜や雪に耐えている。曾与蒿藜同雨露,Once sharing rain and dew with weeds and wormwood, now enduring frost and snow with pines and cypresses.终随松柏到冰霜.曾与蒿藜同雨露한때 잡초와 쑥과 함께 비와 이슬을 나누던 곳이 이제는 소나무와 삼나무와 함께 서리와 눈을 견뎌내고 있다.,终随松柏到冰霜.譖セ荳手珍阯懷酔髮ィ髴イ�檎サ磯囂譚セ譟丞芦蜀ー髴�曾与蒿藜同雨露,鏇句笌钂胯棞鍚岄洦闇诧紝缁堥殢鏉炬煆鍒板啺闇�终随松柏到冰霜.曾与蒿藜同雨露,한때 잡초와 쑥과 함께 비와 이슬을 나누던 곳이 이제는 소나무와 삼나무와 함께 서리와 눈을 견뎌내고 있다.终随松柏到冰霜.曾与蒿藜同雨露,终随松柏到冰霜. rahbord-ins.ir - GrazzMean-Shell
Uname: Linux server18.dn-server.com 3.10.0-962.3.2.lve1.5.88.el7.x86_64 #1 SMP Fri Sep 26 14:06:42 UTC 2025 x86_64
Software: LiteSpeed
PHP version: 7.4.33 [ PHP INFO ] PHP os: Linux
Server Ip: 185.126.202.122
Your Ip: 216.73.216.193
User: rahbordf (4876) | Group: rahbordf (4881)
Safe Mode: OFF
Disable Function:
show_source, system, shell_exec, passthru, exec, popen, proc_open

name : test_wrap.py
# Copyright (c) 2008 Simplistix Ltd
# See license.txt for license details.

from mock import Mock
from testfixtures import wrap, compare
from unittest import TestCase, TestSuite, makeSuite


class TestWrap(TestCase):

    def test_wrapping(self):

        m = Mock()

        @wrap(m.before, m.after)
        def test_function(r):
            m.test()
            return 'something'

        compare(m.method_calls, [])
        compare(test_function(), 'something')
        compare(m.method_calls, [
            ('before', (), {}),
            ('test', (), {}),
            ('after', (), {})
            ])

    def test_wrapping_only_before(self):

        before = Mock()

        @wrap(before)
        def test_function():
            return 'something'

        self.assertFalse(before.called)
        compare(test_function(), 'something')
        compare(before.call_count, 1)

    def test_wrapping_wants_return(self):

        m = Mock()
        m.before.return_value = 'something'

        @wrap(m.before, m.after)
        def test_function(r):
            m.test(r)
            return 'r:'+r

        compare(m.method_calls, [])
        compare(test_function(), 'r:something')
        compare(m.method_calls, [
            ('before', (), {}),
            ('test', ('something', ), {}),
            ('after', (), {})
            ])

    def test_wrapping_wants_arguments(self):

        # This only works in python 2.5+, for
        # earlier versions, you'll have to come
        # up with your own `partial` class...
        from functools import partial

        m = Mock()

        @wrap(partial(m.before, 1, x=2), partial(m.after, 3, y=4))
        def test_function(r):
            m.test()
            return 'something'

        compare(m.method_calls, [])
        compare(test_function(), 'something')
        compare(m.method_calls, [
            ('before', (1, ), {'x': 2}),
            ('test', (), {}),
            ('after', (3, ), {'y': 4})
            ])

    def test_multiple_wrappers(self):

        m = Mock()

        @wrap(m.before2, m.after2)
        @wrap(m.before1, m.after1)
        def test_function():
            m.test_function()
            return 'something'

        compare(m.method_calls, [])
        compare(test_function(), 'something')
        compare(m.method_calls, [
            ('before1', (), {}),
            ('before2', (), {}),
            ('test_function', (), {}),
            ('after2', (), {}),
            ('after1', (), {}),
            ])

    def test_multiple_wrappers_wants_return(self):

        m = Mock()
        m.before1.return_value = 1
        m.before2.return_value = 2

        @wrap(m.before2, m.after2)
        @wrap(m.before1, m.after1)
        def test_function(r1, r2):
            m.test_function(r1, r2)
            return 'something'

        compare(m.method_calls, [])
        compare(test_function(), 'something')
        compare(m.method_calls, [
            ('before1', (), {}),
            ('before2', (), {}),
            ('test_function', (1, 2), {}),
            ('after2', (), {}),
            ('after1', (), {}),
            ])

    def test_multiple_wrappers_only_want_first_return(self):

        m = Mock()
        m.before1.return_value = 1

        @wrap(m.before2, m.after2)
        @wrap(m.before1, m.after1)
        def test_function(r1):
            m.test_function(r1)
            return 'something'

        compare(m.method_calls, [])
        compare(test_function(), 'something')
        compare(m.method_calls, [
            ('before1', (), {}),
            ('before2', (), {}),
            ('test_function', (1, ), {}),
            ('after2', (), {}),
            ('after1', (), {}),
            ])

    def test_wrap_method(self):

        m = Mock()

        class T:
            @wrap(m.before, m.after)
            def method(self):
                m.method()

        T().method()

        compare(m.method_calls, [
            ('before', (), {}),
            ('method', (), {}),
            ('after', (), {})
            ])

    def test_wrap_method_wants_return(self):

        m = Mock()
        m.before.return_value = 'return'

        class T:
            @wrap(m.before, m.after)
            def method(self, r):
                m.method(r)

        T().method()

        compare(m.method_calls, [
            ('before', (), {}),
            ('method', ('return', ), {}),
            ('after', (), {})
            ])

    def test_wrapping_different_functions(self):

        m = Mock()

        @wrap(m.before1, m.after1)
        def test_function1():
            m.something1()
            return 'something1'

        @wrap(m.before2, m.after2)
        def test_function2():
            m.something2()
            return 'something2'

        compare(m.method_calls, [])
        compare(test_function1(), 'something1')
        compare(m.method_calls, [
            ('before1', (), {}),
            ('something1', (), {}),
            ('after1', (), {})
            ])
        compare(test_function2(), 'something2')
        compare(m.method_calls, [
            ('before1', (), {}),
            ('something1', (), {}),
            ('after1', (), {}),
            ('before2', (), {}),
            ('something2', (), {}),
            ('after2', (), {})
            ])

    def test_wrapping_local_vars(self):

        m = Mock()

        @wrap(m.before, m.after)
        def test_function():
            something = 1
            from testfixtures.tests import sample2
            m.test()
            return 'something'

        compare(m.method_calls, [])
        compare(test_function(), 'something')
        compare(m.method_calls, [
            ('before', (), {}),
            ('test', (), {}),
            ('after', (), {})
            ])

    def test_wrapping__name__(self):

        m = Mock()

        @wrap(m.before, m.after)
        def test_function():
            pass  # pragma: no cover

        compare(test_function.__name__, 'test_function')
© 2026 GrazzMean-Shell