July 22nd, 2016

404

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

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


КАК? КАККА??????