Source

friday-skill-up / library / utils.py

Full commit
# -*- coding: utf-8 -*-

from mock import patch
import itertools  # важно: мы импортируем модуль, не сам метод


__author__ = 'mindinpanic'

from itertools import permutations

def real(name):
    if len(name) < 10:
        raise ValueError('String too short to calculate statistics.')

    y = 0
    p = permutations(xrange(len(name)), 10)
    for i in p:
        for j in i:
            y += j
            print y

name = 'достаточно длинное имя'


@patch('itertools.permutations')
def test(ip):
    ip.return_value = range(5)
    real(name)
#    print list(itertools.permutations(xrange(10), 10))

test()