<commit_before>import pytest

from ..send_self import (
    send_self,
    send_self_return,
    WaitTimeoutError,
    WeakGeneratorWrapper,
    StrongGeneratorWrapper
)

from . import CustomError


class TestSendSelfEnvironment(object):

    def test_wrapper_type(self):
        run = False

        @send_self
        def func():
            nonlocal run
            this = yield
            assert type(this) is WeakGeneratorWrapper
            run = True

        assert type(func() is StrongGeneratorWrapper)
        assert run

    def test_send_self_return(self):
        val = 123 + id(self)
        run = False

        @send_self_return
        def func():
            nonlocal val, run
            this = yield val
            assert type(this) is WeakGeneratorWrapper
            run = True

        assert func() == val
        assert run

    def test_not_catch_stopiteration(self):<commit_msg>Add tests for proper wrapping of the generator<commit_after>import pytest

from ..send_self import (
    send_self,
    send_self_return,
    WeakGeneratorWrapper,
    StrongGeneratorWrapper
)

from . import CustomError


class TestSendSelfEnvironment(object):

    def test_wrapper_type(self):
        run = False

        @send_self
        def func():
            nonlocal run
            this = yield
            assert type(this) is WeakGeneratorWrapper
            run = True

        assert type(func() is StrongGeneratorWrapper)
        assert run

    def test_send_self_return(self):
        val = 123 + id(self)
        run = False

        @send_self_return
        def func():
            nonlocal val, run
            this = yield val
            assert type(this) is WeakGeneratorWrapper
            run = True

        assert func() == val
        assert run

    def test_wrapping(self):
        def func():
            """generic docstring"""
            yield

        attributes = ["__%s__" % a
                      for a in 'doc,name,module,annotations'.split(',')]

        for cls in (send_self,       send_self_return,
                    send_self(True), send_self_return(True)):
            wrapped = cls(func)
            for attr in attributes:
                if hasattr(wrapped, attr):
                    assert getattr(wrapped, attr) == getattr(func, attr)

            if hasattr(wrapped, '__wrapped__'):
                assert wrapped.__wrapped__ is func

    def test_not_catch_stopiteration(self):
{'fraction_non_alphanumeric': 0.07043407043407043, 'fraction_numerical': 0.002457002457002457, 'mean_word_length': 1.8440046565774155, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2732972', 'n_tokens_mistral': 669, 'n_tokens_neox': 636, 'n_words': 181}