# Path: expremigen/patterns/prand.py
# class Prand(Pattern):
#     """
#     Pattern used to draw random numbers from a list
#     (numbers may repeat themselves)
#     """
# 
#     def __init__(self, alist=None, repeats=sys.maxsize):
#         """
#         pattern that
#         :param alist: possible numbers
#         :param repeats: how many numbers to draw
#         """
#         super().__init__()
#         if alist is None:
#             alist = []
#         self.alist = copy.deepcopy(alist)
#         self.repeats = repeats
# 
#     def __iter__(self):
#         # following shuffles the list after repeating
#         return flatten(take(self.repeats, (i for i in random_permutation(
#             itertools.chain.from_iterable(itertools.repeat(self.alist, self.repeats))))))
# 
#     def __str__(self):
#         return "{0}({1}, {2})".format(self.__class__.__name__, self.alist, self.repeats)


import unittest
from expremigen.patterns.prand import Prand



class TestPrand(unittest.TestCase):
    def test_shorter(self):
        a = [i for i in Prand([4, 5, 6], 2)]
        self.assertEqual(len(a), 2)

    def test_longer(self):
        b = [i for i in Prand([4, 5, 6], 10)]
        self.assertEqual(len(b), 10)

    def test_repr(self):

# Path: expremigen/patterns/prand.py
# class Prand(Pattern):
#     """
#     Pattern used to draw random numbers from a list
#     (numbers may repeat themselves)
#     """
# 
#     def __init__(self, alist=None, repeats=sys.maxsize):
#         """
#         pattern that
#         :param alist: possible numbers
#         :param repeats: how many numbers to draw
#         """
#         super().__init__()
#         if alist is None:
#             alist = []
#         self.alist = copy.deepcopy(alist)
#         self.repeats = repeats
# 
#     def __iter__(self):
#         # following shuffles the list after repeating
#         return flatten(take(self.repeats, (i for i in random_permutation(
#             itertools.chain.from_iterable(itertools.repeat(self.alist, self.repeats))))))
# 
#     def __str__(self):
#         return "{0}({1}, {2})".format(self.__class__.__name__, self.alist, self.repeats)


# Path: tests/testprand.py
import unittest
from expremigen.patterns.prand import Prand




class TestPrand(unittest.TestCase):
    def test_shorter(self):
        a = [i for i in Prand([4, 5, 6], 2)]
        self.assertEqual(len(a), 2)

    def test_longer(self):
        b = [i for i in Prand([4, 5, 6], 10)]
        self.assertEqual(len(b), 10)

    def test_repr(self):

        self.assertEqual("{0}".format(Prand([1, -1, 2], 3)), "Prand([1, -1, 2], 3)")