My favorites | Sign in
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

import unittest

_TESTSTR = '0123456789-abcdefghijklmnopqrstuvwxyz-'

def _generate_test_string(length):
"""
Returns a string of `length` characters, constructed by repeating _TESTSTR as necessary.

To enhance performance, there are 3 ways data is read, based on the length of the value, so most data types are
tested with 3 lengths. This function helps us generate the test data.

We use a recognizable data set instead of a single character to make it less likely that "overlap" errors will
be hidden and to help us manually identify where a break occurs.
"""
if length <= len(_TESTSTR):
return _TESTSTR[:length]

c = (length + len(_TESTSTR)-1) / len(_TESTSTR)
v = _TESTSTR * c
return v[:length]

class TestBase(unittest.TestCase):


Change log

c278e74e4434 by Michael Kleehammer <mich...@kleehammer.com> on Nov 2, 2011   Diff
Single source base for Python 2 and 3
Go to: 
Sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 819 bytes, 25 lines
Powered by Google Project Hosting