Contains main functions and facilities you will need when using pyquchk. They all can be imported with from pyquchk import ..., no need to specify exact modules.
Decorator for a test function.
For usage examples see Writing and running tests.
Parameters: | ntests – number of tests |
---|
Test the function func on _ntests tests.
For usage examples see Property checking.
Parameters: | kwargs – function arguments specification |
---|---|
Returns: | information about the tests run |
Return type: | Result |
Represent the result of performed testing (returned by for_all()).
Data on which the tested function failed (as a dict), or None if passed
List of all the data values generated during the test run
Exception raised by the function, or ReturnedFalse if function returned False, or None if passed
Exception traceback, or None if passed
'OK' if passed and 'FAIL' if not
Automatically raised when the tested function returns a value which evaluates to a bool False.
Exact value returned by the function (evaluates to a False bool value)
Raised when a test which uses qc() decorator fails.
It contains the original test data for which the test has failed, and the exception raised by the tested function. Actually, a CheckError instance is always also an instance of the exception raised by the tested function, so you can except it as usually.
Exception raised by the function, or ReturnedFalse if function returned False
Data which caused the function to raise an exception
Decorator for decorators (sic) that are intended to take optional arguments.
It supports decorators written both as classes or functions, as long as they are “doubly-callable”. For classes, this means implementing __call__, while functions must return a function that returns a function that accepts a function... which is obvious, of course.
A Sequence whose values are computed lazily by an iterator.
>>> it = count()
>>> ll = LazyList(it)
>>> list(ll[:10])
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> list(ll[:10])
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> list(ll[:10])
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> ll[123]
123
>>> list(ll[1:10:2])
[1, 3, 5, 7, 9]
Get an item from a LazyList. i should be a positive integer or a slice object.
Return an iterator over each value in the sequence, whether it has been computed yet or not.
Contains all the built-in Arbitrary instances. They all can be imported with from pyquchk.arbitraries import ..., no need to specify exact modules.
Contains Arbitrary class and the machinery it needs to work. You shouldn’t need anything other than this class from here.
Base class for all arbitraries, both built-in and custom.
To create a custom arbitrary, you need to subclass from Arbitrary and override (some or all) instance methods listed below.
Check if x could’ve been generated by self.
Required iff you use decorators like filter_possible() or until_possible().
Contain utility functions and decorators useful when defining custom Arbitrary instances. Usually they haven’t much use otherwise.
Yield items from the given iterables in a round-robin fashion.
What it does exactly is better explained with a simple example:
>>> list(roundrobin(['ABC', 'D', 'EF']))
['A', 'D', 'E', 'B', 'F', 'C']
Parameters: | iterables – List of finite or infinite iterables. |
---|
>>> list(interleave([], []))
[]
>>> list(interleave([1], []))
[1]
>>> list(interleave([], ['a']))
['a']
>>> list(interleave([1], ['a']))
[1, 'a']
>>> list(interleave([1, 2], ['a']))
[1, 'a', 2]
>>> list(interleave([1], ['a', 'b']))
[1, 'a', 'b']
>>> list(interleave([1, 2], ['a', 'b']))
[1, 'a', 2, 'b']
Cartesian product of all the iterables.
Difference compared to the itertools.product() is that tuples are yield in the order suitable for infinite iterables (see examples below).
Corner cases:
>>> list(product([], []))
[]
>>> list(product([1, 2, 3], []))
[]
>>> list(product([], [1, 2, 3]))
[]
2 iterables:
>>> list(product([1], [1]))
[(1, 1)]
>>> list(product([1, 2], [1]))
[(1, 1), (2, 1)]
>>> list(product([1, 2], [1, 2]))
[(1, 1), (1, 2), (2, 1), (2, 2)]
>>> list(product([1, 2, 3], [1, 2, 3]))
[(1, 1), (1, 2), (2, 1), (2, 2), (1, 3), (2, 3), (3, 1), (3, 2), (3, 3)]
>>> list(product([1, 2, 3], [1, 2, 3])) == list(product([1, 2, 3], repeat=2))
True
>>> list(islice(product(count(1), count(1)), 1000)) == list(islice(product(count(1), repeat=2), 1000))
True
>>> infNN = product(count(1), count(1))
>>> list(islice(infNN, 20))
[(1, 1), (1, 2), (2, 1), (2, 2), (1, 3), (2, 3), (3, 1), (3, 2), (3, 3), (1, 4), (2, 4), (3, 4), (4, 1), (4, 2), (4, 3), (4, 4), (1, 5), (2, 5), (3, 5), (4, 5)]
>>> lstNN = list(islice(infNN, 10000))
>>> all(max(x) <= max(y) for x, y in zip(lstNN, lstNN[1:]))
True
3 iterables:
>>> list(product([1, 2], [1, 2], [1, 2]))
[(1, 1, 1), (1, 1, 2), (1, 2, 1), (1, 2, 2), (2, 1, 1), (2, 1, 2), (2, 2, 1), (2, 2, 2)]
>>> len(list(product([1, 2, 3], [1, 2, 3], [1, 2, 3])))
27
>>> infNNN = product(count(1), count(1), count(1))
>>> list(islice(infNNN, 20))
[(1, 1, 1), (1, 1, 2), (1, 2, 1), (1, 2, 2), (2, 1, 1), (2, 1, 2), (2, 2, 1), (2, 2, 2), (1, 1, 3), (1, 2, 3), (2, 1, 3), (2, 2, 3), (1, 3, 1), (1, 3, 2), (1, 3, 3), (2, 3, 1), (2, 3, 2), (2, 3, 3), (3, 1, 1), (3, 1, 2)]
>>> lstNNN = list(islice(infNNN, 10000))
>>> all(max(x) <= max(y) for x, y in zip(lstNNN, lstNNN[1:]))
True
Like random.choice(), but the probability an item is chosen is proportional to its weight.
For convenience, this function is available as random.choice_weighted if you imported utils.
Parameters: | elements – list of tuples (item, weight), weight is any numeric value |
---|
Decorator, when applied to a generator method (e.g. gen_serial()) filters generated values to keep only those for which could_generate() returns True.
Decorator, when applied to a method returning different values each time (e.g. next_random()) runs this method multiple times until a value for which could_generate() returns True is returned, and finally returns this value.
Decorator, when applied to a generator method (e.g. gen_serial(), shrink()) filters generated values to keep only unique values. For the shrink() method the value passed to the method is also considered.
Any constant value.
Sample values
>>> arb = const(value='abc')
>>> list(islice(arb.gen_random(), 20))
['abc',
'abc',
'abc',
'abc',
'abc',
'abc',
'abc',
'abc',
'abc',
'abc',
'abc',
'abc',
'abc',
'abc',
'abc',
'abc',
'abc',
'abc',
'abc',
'abc']
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
['abc']
<note: exact output may differ>
Choice from a list of constant values.
Sample values
>>> arb = elements('a', 'b', 'c', 'd')
>>> list(islice(arb.gen_random(), 20))
['d',
'b',
'd',
'd',
'c',
'b',
'd',
'c',
'a',
'c',
'c',
'b',
'a',
'a',
'd',
'd',
'b',
'b',
'b',
'b']
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
['a', 'b', 'c', 'd']
<note: exact output may differ>
Choice (possible weighed) from a list of Arbitraries.
Sample values
>>> arb = oneof(const('a'), const('b'), const('c'))
>>> list(islice(arb.gen_random(), 20))
['a',
'b',
'a',
'b',
'a',
'a',
'a',
'c',
'a',
'c',
'c',
'b',
'b',
'c',
'a',
'b',
'a',
'c',
'c',
'b']
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
['a', 'b', 'c']
<note: exact output may differ>
Any bool value (False or True).
Sample values
>>> arb = bool_()
>>> list(islice(arb.gen_random(), 20))
[True,
True,
False,
False,
False,
True,
False,
False,
True,
False,
False,
False,
True,
True,
True,
True,
True,
False,
True,
False]
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
[False, True]
<note: exact output may differ>
Any single character (string of length one).
Sample values
>>> arb = char()
>>> list(islice(arb.gen_random(), 20))
['{',
'o',
'z',
'\xaa',
'\xbf',
'5',
'\x1e',
'\xd5',
'=',
'\xee',
'\x0f',
'\xc1',
'\xda',
'e',
'\xc6',
'\x1f',
'\xce',
'\xe5',
'\x1c',
'\x05']
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
['\x00',
'\x01',
'\x02',
'\x03',
'\x04',
'\x05',
'\x06',
'\x07',
'\x08',
'\t',
'\n',
'\x0b',
'\x0c',
'\r',
'\x0e',
'\x0f',
'\x10',
'\x11',
'\x12',
'\x13',
'\x14',
'\x15',
'\x16',
'\x17',
'\x18',
'\x19',
'\x1a',
'\x1b',
'\x1c',
'\x1d',
'\x1e',
'\x1f',
' ',
'!',
'"',
'#',
'$',
'%',
'&',
"'",
'(',
')',
'*',
'+',
',',
'-',
'.',
'/',
'0',
'1']
<note: exact output may differ>
Lower and upper latin letters.
Sample values
>>> arb = letter()
>>> list(islice(arb.gen_random(), 20))
['D',
'N',
'A',
'B',
'O',
'm',
'j',
'y',
'b',
'i',
'm',
'e',
'g',
'E',
'L',
'k',
'K',
'g',
'B',
'w']
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
['a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X']
<note: exact output may differ>
Uniformly distributed integer from the specified range.
Sample values
>>> arb = int_()
>>> list(islice(arb.gen_random(), 20))
[-48,
417,
2094,
-11891,
-48148,
-364026684,
361506,
15600149,
-216552393,
-790788815,
107,
1152426122,
-97515852,
-5582117,
32,
946338954,
-81095,
51,
1281229,
-27]
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
[0,
1,
-4294967296,
4294967295,
-1,
2,
-2,
3,
-3,
4,
-4,
5,
-5,
6,
-6,
7,
-7,
8,
-8,
9,
-9,
10,
-10,
11,
-11,
12,
-12,
13,
-13,
14,
-14,
15,
-15,
16,
-16,
17,
-17,
18,
-18,
19,
-19,
20,
-20,
21,
-21,
22,
-22,
23,
-23,
24]
<note: exact output may differ>
Float with significand, exponent and sign taken according to the parameters.
Sample values
>>> arb = float_()
>>> list(islice(arb.gen_random(), 20))
[4.048137530632166e-05,
0.824689994696606,
1.5006740746388167,
3.2788071838907715,
-0.9281410936041669,
1.8701437487092052,
4.524243828387623e-09,
0.0475079790732711,
63.02759966366083,
-0.12189377299057169,
1.9597732510712929,
22.82720059362635,
0.9006486692327069,
-0.27229023576652445,
-7.703409417817684e-11,
-5.6250823897229695e-05,
0.5774981328877355,
-0.47949965763068997,
-0.46299429460884306,
0.006682216261832196]
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
[0,
-100.0,
100.0,
0.5,
1.0,
-0.5,
-1.0,
5.820766091346741e-11,
-5.820766091346741e-11,
64.0,
-64.0,
0.25,
-0.25,
0.75,
1.5,
8.731149137020111e-11,
96.0,
0.375,
-0.75,
-1.5,
-8.731149137020111e-11,
-96.0,
-0.375,
2.0,
3.0,
-2.0,
-3.0,
0.125,
0.1875,
-0.125,
-0.1875,
0.625,
1.25,
7.275957614183426e-11,
80.0,
0.3125,
2.5,
0.15625,
-0.625,
-1.25,
-7.275957614183426e-11,
-80.0,
-0.3125,
-2.5,
-0.15625,
4.0,
6.0,
5.0,
-4.0,
-6.0]
<note: exact output may differ>
Tuple with specified elements.
Sample values
>>> arb = tuple_((int_, letter))
>>> list(islice(arb.gen_random(), 20))
[(152, 'l'),
(-74, 'f'),
(-10, 'o'),
(111, 'I'),
(-304, 'u'),
(9674671, 'y'),
(-789, 't'),
(-1229, 't'),
(-145119819, 'E'),
(415580491, 'G'),
(438383, 'O'),
(0, 'n'),
(-1692454, 'M'),
(-123573, 'B'),
(-40328350, 'j'),
(-458032062, 'G'),
(-1, 'Z'),
(1412391881, 's'),
(-803, 'U'),
(-204691011, 'V')]
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
[(0, 'a'),
(0, 'b'),
(1, 'a'),
(1, 'b'),
(0, 'c'),
(1, 'c'),
(-4294967296, 'a'),
(-4294967296, 'b'),
(-4294967296, 'c'),
(0, 'd'),
(1, 'd'),
(-4294967296, 'd'),
(4294967295, 'a'),
(4294967295, 'b'),
(4294967295, 'c'),
(4294967295, 'd'),
(0, 'e'),
(1, 'e'),
(-4294967296, 'e'),
(4294967295, 'e'),
(-1, 'a'),
(-1, 'b'),
(-1, 'c'),
(-1, 'd'),
(-1, 'e'),
(0, 'f'),
(1, 'f'),
(-4294967296, 'f'),
(4294967295, 'f'),
(-1, 'f'),
(2, 'a'),
(2, 'b'),
(2, 'c'),
(2, 'd'),
(2, 'e'),
(2, 'f'),
(0, 'g'),
(1, 'g'),
(-4294967296, 'g'),
(4294967295, 'g'),
(-1, 'g'),
(2, 'g'),
(-2, 'a'),
(-2, 'b'),
(-2, 'c'),
(-2, 'd'),
(-2, 'e'),
(-2, 'f'),
(-2, 'g'),
(0, 'h')]
<note: exact output may differ>
List with configurable length and elements.
Sample values
>>> arb = list_(length=int_(0, 10), elements=int_(-100, 100))
>>> list(islice(arb.gen_random(), 20))
[[-14],
[],
[],
[],
[-24, 26, 1, -8, 2, 49],
[],
[30, 0, 51, -13, -2, 0, 50, 1],
[],
[7, 6, 11],
[56, -58, -6, -5, -62, -3, 2, 2, -2, -99],
[1, 1, 18, -32, -4, -6, 4, 29, 9],
[-5, 44],
[],
[15],
[],
[],
[20, -4, -55, -17, 0, -7, -21, 57, 13, 48],
[-9, 1],
[0, 3, -1, 40, 0, 35, 1, -53, 0, 0],
[19, -1]]
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
[[],
[0],
[1],
[-100],
[0, 0],
[0, 1],
[1, 0],
[1, 1],
[0, -100],
[1, -100],
[-100, 0],
[-100, 1],
[-100, -100],
[100],
[0, 100],
[1, 100],
[-100, 100],
[100, 0],
[100, 1],
[100, -100],
[100, 100],
[0, 0, 0],
[0, 0, 1],
[0, 1, 0],
[0, 1, 1],
[1, 0, 0],
[1, 0, 1],
[1, 1, 0],
[1, 1, 1],
[0, 0, -100],
[0, 1, -100],
[1, 0, -100],
[1, 1, -100],
[0, -100, 0],
[0, -100, 1],
[0, -100, -100],
[1, -100, 0],
[1, -100, 1],
[1, -100, -100],
[-100, 0, 0],
[-100, 0, 1],
[-100, 0, -100],
[-100, 1, 0],
[-100, 1, 1],
[-100, 1, -100],
[-100, -100, 0],
[-100, -100, 1],
[-100, -100, -100],
[0, 0, 100],
[0, 1, 100]]
<note: exact output may differ>
List where elements are in order.
Note
Non-unique serially-generated values and shrink results are possible.
Sample values
>>> arb = list_ordered(length=int_(0, 10), elements=int_(-100, 100))
>>> list(islice(arb.gen_random(), 20))
[[-2, -1, 0, 2],
[-93, -43, -20, -1, 1, 2],
[0],
[6],
[-82, -78, 0, 9],
[],
[3, 37],
[],
[-12, -7, 0, 1, 4, 13],
[1],
[-57],
[],
[-50, 1, 21],
[-85, -63, -2, 0],
[],
[],
[-2, -1, 4, 14, 82],
[-15, -8, 0, 0, 3],
[-4, -1],
[-73, -54, -2, 0, 1, 3, 14, 35, 60]]
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
[[],
[0],
[1],
[-100],
[0, 0],
[0, 1],
[0, 1],
[1, 1],
[-100, 0],
[-100, 1],
[-100, 0],
[-100, 1],
[-100, -100],
[100],
[0, 100],
[1, 100],
[-100, 100],
[0, 100],
[1, 100],
[-100, 100],
[100, 100],
[0, 0, 0],
[0, 0, 1],
[0, 0, 1],
[0, 1, 1],
[0, 0, 1],
[0, 1, 1],
[0, 1, 1],
[1, 1, 1],
[-100, 0, 0],
[-100, 0, 1],
[-100, 0, 1],
[-100, 1, 1],
[-100, 0, 0],
[-100, 0, 1],
[-100, -100, 0],
[-100, 0, 1],
[-100, 1, 1],
[-100, -100, 1],
[-100, 0, 0],
[-100, 0, 1],
[-100, -100, 0],
[-100, 0, 1],
[-100, 1, 1],
[-100, -100, 1],
[-100, -100, 0],
[-100, -100, 1],
[-100, -100, -100],
[0, 0, 100],
[0, 1, 100]]
<note: exact output may differ>
List with unique elements.
Warning
Implementation just keeps generating random lists until one with unique elements is found, so for some parameters it can be very slow. Also, upper length bound is never reached in some cases.
Sample values
>>> arb = list_unique(length=int_(0, 10), elements=int_(-100, 100))
>>> list(islice(arb.gen_random(), 20))
[[],
[-11],
[-1, -6],
[32, -93, 44, -48, 18, 2, 1],
[1, -1, 46],
[],
[60],
[],
[46],
[3, -23],
[-9, 57],
[-15],
[-49],
[3],
[-39],
[],
[10, -11],
[-98],
[1],
[37]]
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
[[],
[0],
[1],
[-100],
[0, 1],
[1, 0],
[0, -100],
[1, -100],
[-100, 0],
[-100, 1],
[100],
[0, 100],
[1, 100],
[-100, 100],
[100, 0],
[100, 1],
[100, -100],
[0, 1, -100],
[1, 0, -100],
[0, -100, 1],
[1, -100, 0],
[-100, 0, 1],
[-100, 1, 0],
[0, 1, 100],
[0, -100, 100],
[1, 0, 100],
[1, -100, 100],
[-100, 0, 100],
[-100, 1, 100],
[0, 100, 1],
[0, 100, -100],
[1, 100, 0],
[1, 100, -100],
[-100, 100, 0],
[-100, 100, 1],
[100, 0, 1],
[100, 0, -100],
[100, 1, 0],
[100, 1, -100],
[100, -100, 0],
[100, -100, 1],
[-1],
[0, -1],
[1, -1],
[-100, -1],
[100, -1],
[-1, 0],
[-1, 1],
[-1, -100],
[-1, 100]]
<note: exact output may differ>
Set of unique elements.
Warning
Implementation just keeps generating random lists until one with unique elements is found, so for some parameters it can be very slow. Also, upper length bound is never reached in some cases.
Note
Non-unique serially-generated values and shrink results are possible.
Sample values
>>> arb = set_()
>>> list(islice(arb.gen_random(), 20))
[{513, 278916385},
{1},
{107737667},
set(),
{-358366, -280, 464093},
set(),
set(),
{45348362},
{-355, -1, 196},
{-72203944, -122684, 2, 33, 893},
{-52632, 28794, 672646069},
{-2966374908, -23426, -6668, 29919, 75740},
{-2714, 1, 5, 173, 339},
{-58630852, -37150699, -923756, -129689, 61},
{-1164, 0, 4, 36112283, 731483077},
set(),
{9856},
{-9857961},
{346},
set()]
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
[set(),
{0},
{1},
{-4294967296},
{0, 1},
{0, 1},
{-4294967296, 0},
{-4294967296, 1},
{-4294967296, 0},
{-4294967296, 1},
{4294967295},
{0, 4294967295},
{1, 4294967295},
{-4294967296, 4294967295},
{0, 4294967295},
{1, 4294967295},
{-4294967296, 4294967295},
{-4294967296, 0, 1},
{-4294967296, 0, 1},
{-4294967296, 0, 1},
{-4294967296, 0, 1},
{-4294967296, 0, 1},
{-4294967296, 0, 1},
{0, 1, 4294967295},
{-4294967296, 0, 4294967295},
{0, 1, 4294967295},
{-4294967296, 1, 4294967295},
{-4294967296, 0, 4294967295},
{-4294967296, 1, 4294967295},
{0, 1, 4294967295},
{-4294967296, 0, 4294967295},
{0, 1, 4294967295},
{-4294967296, 1, 4294967295},
{-4294967296, 0, 4294967295},
{-4294967296, 1, 4294967295},
{0, 1, 4294967295},
{-4294967296, 0, 4294967295},
{0, 1, 4294967295},
{-4294967296, 1, 4294967295},
{-4294967296, 0, 4294967295},
{-4294967296, 1, 4294967295},
{-1},
{-1, 0},
{-1, 1},
{-4294967296, -1},
{-1, 4294967295},
{-1, 0},
{-1, 1},
{-4294967296, -1},
{-1, 4294967295}]
<note: exact output may differ>
Dictionary with specified items (key-value pairs) arbitrary.
Note
Non-unique serially-generated values and shrink results are possible.
Sample values
>>> arb = dict_()
>>> list(islice(arb.gen_random(), 20))
[{-59: -31},
{},
{},
{-6401037: -5,
-3286841: 515,
-82059: -3745,
-11174: -3,
-13: 26171,
5: -12,
7: -6,
231: 1751,
11102: 53780886,
157052: -8541725,
303889: 7,
27456559: 124,
827916829: 0},
{495701643: 1143900518},
{},
{-2005881545: 158659,
-986421493: 25977363,
-59028387: 16284,
-29: -132843,
405704: 2,
70822477: 4,
312547055: 20},
{},
{15: -1091535516},
{-9145: 740, 5: 1, 1832268: 1585},
{},
{},
{-19395929: -146, -40: -424, -18: 5950, 0: 1551592},
{},
{53: 134},
{},
{4493: 1315, 132130: -1596354, 250920: 12337},
{-508563929: 5714, -1: -15},
{},
{-1976887560: -1367812717,
-206621936: -42190199,
-57217388: -25517613,
-1043819: -52962441,
-725469: -22787,
-12151: -31233,
-6217: 2303798891,
2: -67,
3: -2916,
254: -1,
3602: -4984,
14091: -529,
3160911: 11405,
77826990: -93233,
900934283: 55159362}]
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
[{},
{0: 0},
{0: 1},
{1: 0},
{1: 1},
{0: -4294967296},
{1: -4294967296},
{-4294967296: 0},
{-4294967296: 1},
{-4294967296: -4294967296},
{0: 0, 1: 0},
{0: 0, 1: 1},
{0: 1, 1: 0},
{-4294967296: 0, 0: 0},
{-4294967296: 1, 0: 0},
{-4294967296: 0, 0: 1},
{0: 1, 1: 1},
{-4294967296: 1, 0: 1},
{-4294967296: 0, 1: 0},
{-4294967296: 1, 1: 0},
{-4294967296: 0, 1: 1},
{-4294967296: 1, 1: 1},
{0: 0, 1: -4294967296},
{0: -4294967296, 1: 0},
{-4294967296: -4294967296, 0: 0},
{-4294967296: -4294967296, 1: 0},
{-4294967296: 0, 0: 0},
{-4294967296: 0, 0: 1},
{-4294967296: 1, 0: 0},
{-4294967296: 1, 0: 1},
{-4294967296: 0, 0: -4294967296},
{0: 1, 1: -4294967296},
{0: -4294967296, 1: 1},
{-4294967296: -4294967296, 0: 1},
{-4294967296: -4294967296, 1: 1},
{-4294967296: 1, 0: -4294967296},
{-4294967296: 0, 1: -4294967296},
{-4294967296: 1, 1: -4294967296},
{-4294967296: 0, 0: -4294967296},
{-4294967296: -4294967296, 0: 0},
{4294967295: 0},
{4294967295: 1},
{4294967295: -4294967296},
{-4294967296: 1, 0: -4294967296},
{-4294967296: -4294967296, 0: 1},
{0: 0, 4294967295: 0},
{0: 0, 4294967295: 1},
{0: 1, 4294967295: 0},
{0: 1, 4294967295: 1},
{0: 0, 4294967295: -4294967296}]
<note: exact output may differ>
Mutable bytearray with configurable length and elements.
Sample values
>>> arb = bytearray_()
>>> list(islice(arb.gen_random(), 20))
[bytearray(b'\x03\x86\x03;\xf2\x01\n\x02'),
bytearray(b'\x0e\x02\x00\x03\x16\x83-\x04\xaf\n\x0b|'),
bytearray(b'\x07\x01'),
bytearray(b'\x03\x00\x00\x04\xa9\x01\x03'),
bytearray(b'\x06\x01\x00\x02q\x1d'),
bytearray(b'\x02\x07 U\x01:\xfc\x1c\x00'),
bytearray(b'\r\x00x\x1c\n\x01\x04~\x02\x019\x01\x063\x02'),
bytearray(b'd:'),
bytearray(b'\x00\xb3'),
bytearray(b''),
bytearray(b'\xa9\r\x14\x9f\x0et\x02\x04'),
bytearray(b'4\x03B\x03\x03\x02\x13M\r\x0e\x00\x03'),
bytearray(b'\x03'),
bytearray(b'\xbc\xef\x18\x01\x0e\x01'),
bytearray(b'\x10\x04\x00\x08\x00\x92\x05\x16\x01\x01'),
bytearray(b'\x01S'),
bytearray(b'\x03'),
bytearray(b'\x0e'),
bytearray(b'\xaf\x04\x14'),
bytearray(b'\x03\x01\x00\xa7\x1b\x1f\x0e\x1d?-\x01\x1c\x01\x01')]
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
[bytearray(b''),
bytearray(b'\x00'),
bytearray(b'\x01'),
bytearray(b'\xff'),
bytearray(b'\x00\x00'),
bytearray(b'\x00\x01'),
bytearray(b'\x01\x00'),
bytearray(b'\x01\x01'),
bytearray(b'\x00\xff'),
bytearray(b'\x01\xff'),
bytearray(b'\xff\x00'),
bytearray(b'\xff\x01'),
bytearray(b'\xff\xff'),
bytearray(b'\x02'),
bytearray(b'\x00\x02'),
bytearray(b'\x01\x02'),
bytearray(b'\xff\x02'),
bytearray(b'\x02\x00'),
bytearray(b'\x02\x01'),
bytearray(b'\x02\xff'),
bytearray(b'\x02\x02'),
bytearray(b'\x00\x00\x00'),
bytearray(b'\x00\x00\x01'),
bytearray(b'\x00\x01\x00'),
bytearray(b'\x00\x01\x01'),
bytearray(b'\x01\x00\x00'),
bytearray(b'\x01\x00\x01'),
bytearray(b'\x01\x01\x00'),
bytearray(b'\x01\x01\x01'),
bytearray(b'\x00\x00\xff'),
bytearray(b'\x00\x01\xff'),
bytearray(b'\x01\x00\xff'),
bytearray(b'\x01\x01\xff'),
bytearray(b'\x00\xff\x00'),
bytearray(b'\x00\xff\x01'),
bytearray(b'\x00\xff\xff'),
bytearray(b'\x01\xff\x00'),
bytearray(b'\x01\xff\x01'),
bytearray(b'\x01\xff\xff'),
bytearray(b'\xff\x00\x00'),
bytearray(b'\xff\x00\x01'),
bytearray(b'\xff\x00\xff'),
bytearray(b'\xff\x01\x00'),
bytearray(b'\xff\x01\x01'),
bytearray(b'\xff\x01\xff'),
bytearray(b'\xff\xff\x00'),
bytearray(b'\xff\xff\x01'),
bytearray(b'\xff\xff\xff'),
bytearray(b'\x00\x00\x02'),
bytearray(b'\x00\x01\x02')]
<note: exact output may differ>
Immutable bytearray with configurable length and elements.
Note
In Python 2 it’s the same as str_.
Sample values
>>> arb = bytes_()
>>> list(islice(arb.gen_random(), 20))
['\x01\x00\x08\x1eq\n-',
'\x1b\x00\x0b',
'$',
'\x8e\xb0\x06',
'\xab\x19\x04\x02h\x01:',
'\x07\x08\xff\xec\x00\x01c\x06\x05\x01\x10\x01\tk',
'\x0c(',
'T2\x14H7\\\x0b\x14\x01',
'\x01\x17',
'\x00\x02\xdf\x15\x002\x03',
'\xb7',
'\xc4\x01\x00\x03\x05\x03\x12r',
'\x07',
'\x10\x03\xde\xfeO\xf5\tr\x87Q\x05\x01/\x03\x01',
'|\xd2.\x185\x105\x0c\x02\x037',
'\x11\x01\x02<\xb9\x0c\x0e/\x15\x00\x1d\r\x0c',
'',
'\x08\x1c\x05\t\xd9',
'\x01\x04',
'']
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
['',
'\x00',
'\x01',
'\xff',
'\x00\x00',
'\x00\x01',
'\x01\x00',
'\x01\x01',
'\x00\xff',
'\x01\xff',
'\xff\x00',
'\xff\x01',
'\xff\xff',
'\x02',
'\x00\x02',
'\x01\x02',
'\xff\x02',
'\x02\x00',
'\x02\x01',
'\x02\xff',
'\x02\x02',
'\x00\x00\x00',
'\x00\x00\x01',
'\x00\x01\x00',
'\x00\x01\x01',
'\x01\x00\x00',
'\x01\x00\x01',
'\x01\x01\x00',
'\x01\x01\x01',
'\x00\x00\xff',
'\x00\x01\xff',
'\x01\x00\xff',
'\x01\x01\xff',
'\x00\xff\x00',
'\x00\xff\x01',
'\x00\xff\xff',
'\x01\xff\x00',
'\x01\xff\x01',
'\x01\xff\xff',
'\xff\x00\x00',
'\xff\x00\x01',
'\xff\x00\xff',
'\xff\x01\x00',
'\xff\x01\x01',
'\xff\x01\xff',
'\xff\xff\x00',
'\xff\xff\x01',
'\xff\xff\xff',
'\x00\x00\x02',
'\x00\x01\x02']
<note: exact output may differ>
String with configurable length and characters.
Sample values
>>> arb = str_()
>>> list(islice(arb.gen_random(), 20))
['\xf5xB\xa5\xb5\xbe{\xb7\xb1\xda\xef>\xc4GO\x94,',
'df9\xdd<',
'@L\xc0\x8c^\xba\x8e\xa3\xa7h\x93\xfa4r\x04',
"?\xeb\x1c\x0c\xc8\xd8\xacui'\xb5\r\xa1",
'\xac',
'',
'',
's',
'\xb7',
'Bc\xb1\xc7\x84\xb6<',
'{',
'(\x98\xae~',
'',
'c:D\x17\x0by\x87\xf2\x8f\xe1\xf3:;o',
'\xb8iY!\xe1\xb3k\x8f\x04!\xe8',
'9D\xdaEG~\xfe',
'\xa5',
'',
'"',
'\x85']
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
['',
'\x00',
'\x01',
'\x02',
'\x00\x00',
'\x00\x01',
'\x01\x00',
'\x01\x01',
'\x00\x02',
'\x01\x02',
'\x02\x00',
'\x02\x01',
'\x02\x02',
'\x03',
'\x00\x03',
'\x01\x03',
'\x02\x03',
'\x03\x00',
'\x03\x01',
'\x03\x02',
'\x03\x03',
'\x00\x00\x00',
'\x00\x00\x01',
'\x00\x01\x00',
'\x00\x01\x01',
'\x01\x00\x00',
'\x01\x00\x01',
'\x01\x01\x00',
'\x01\x01\x01',
'\x00\x00\x02',
'\x00\x01\x02',
'\x01\x00\x02',
'\x01\x01\x02',
'\x00\x02\x00',
'\x00\x02\x01',
'\x00\x02\x02',
'\x01\x02\x00',
'\x01\x02\x01',
'\x01\x02\x02',
'\x02\x00\x00',
'\x02\x00\x01',
'\x02\x00\x02',
'\x02\x01\x00',
'\x02\x01\x01',
'\x02\x01\x02',
'\x02\x02\x00',
'\x02\x02\x01',
'\x02\x02\x02',
'\x00\x00\x03',
'\x00\x01\x03']
<note: exact output may differ>
String consisting of letters only.
Sample values
>>> arb = str_letters()
>>> list(islice(arb.gen_random(), 20))
['w',
'lvDfoFcmsNkBMkzuVhv',
'',
'cOLQjRHngRWGhb',
'FMRsGpc',
'RPncaU',
'nyenYn',
'',
'a',
'cyytsmjtDNPUr',
'vCDHoBltd',
'',
'cES',
'lKtgYr',
'',
'',
'H',
'tBD',
'eiNuQc',
'']
<note: exact output may differ>
>>> list(islice(arb.gen_serial(), 50))
['',
'a',
'b',
'c',
'aa',
'ab',
'ba',
'bb',
'ac',
'bc',
'ca',
'cb',
'cc',
'd',
'ad',
'bd',
'cd',
'da',
'db',
'dc',
'dd',
'aaa',
'aab',
'aba',
'abb',
'baa',
'bab',
'bba',
'bbb',
'aac',
'abc',
'bac',
'bbc',
'aca',
'acb',
'acc',
'bca',
'bcb',
'bcc',
'caa',
'cab',
'cac',
'cba',
'cbb',
'cbc',
'cca',
'ccb',
'ccc',
'aad',
'abd']
<note: exact output may differ>