amarao (amarao_san) wrote,
amarao
amarao_san

Мой мозг сломан, я в отчаянии

case1:
test_foo.py:
def test_foo(traceroute, logger):
    t = traceroute.Traceroute(sentinel.args)
    with mock.patch.object(t, "_other_method") as mock_other_method:
        t.foo()

foo.py:
    def foo(self):
        raise Exception
        threads = self._run_threads()
        for active_thread, its_route, its_queue in threads:
            return_value = self._wait_thread(active_thread, its_queue)


Рейзится как и положено:

def foo(self):
> raise Exception
E Exception

Теперь добавляем в foo() yield:
case2:

foo.py:
    def foo(self):
        raise Exception
        threads = self._run_threads()
        for active_thread, its_id, its_queue in threads:
            return_value = self._wait_thread(active_thread, its_queue)
            yield its_id, return_value


Тест проходит:

test_foo.py::test_foo PASSED


КАК? КАККА??????
Tags: python
Subscribe

Recent Posts from This Journal

  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 11 comments

Recent Posts from This Journal