Example #1
0
 def test_lorem_ipsum_max(self):
     """Test that at least max words are in the output of each line"""
     for _ in range_type(5):
         m = random.randrange(21, 100)
         for _ in range_type(10):
             assert generate_lorem_ipsum(n=1, max=m,
                                         html=False).count(' ') < m - 1
Example #2
0
 def test_lorem_ipsum_min(self):
     """Test that at least min words are in the output of each line"""
     for _ in range_type(5):
         m = random.randrange(20, 99)
         for _ in range_type(10):
             assert generate_lorem_ipsum(n=1, min=m,
                                         html=False).count(' ') >= m - 1
Example #3
0
def safe_range(*args):
    """A range that can't generate ranges with a length of more than
    MAX_RANGE items.
    """
    rng = range_type(*args)

    if len(rng) > MAX_RANGE:
        raise OverflowError(
            "Range too big. The sandbox blocks ranges larger than"
            " MAX_RANGE (%d)." % MAX_RANGE)

    return rng
Example #4
0
 def test_lorem_ipsum_n(self):
     """Test that the n (number of lines) works as expected."""
     assert generate_lorem_ipsum(n=0, html=False) == u''
     for n in range_type(1, 50):
         assert generate_lorem_ipsum(n=n,
                                     html=False).count('\n') == (n - 1) * 2