Mercurial > evolve
annotate tests/testlib/random-revs.py @ 6210:6ae0077e416e stable
state: allow to unvendor cbor
This makes evolve fallback to an externally provided version of
the `cbor` library, which in turns allows distributions such as Debian
not to include the vendored `cbor.py` and rely on their own provided
version instead.
The price to pay is the immediate attempt to import the vendored `cbor`,
to circumvent that hgdemandimport never raises `ImportError` immediately.
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Fri, 01 Apr 2022 21:59:32 +0200 |
parents | 11b8f7003713 |
children |
rev | line source |
---|---|
5611
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
2 """ |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
3 This simple script outputs a sequence of numbers separated by newlines. The |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
4 amount of numbers and their approximate values can be controlled by two command |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
5 line arguments. |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
6 |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
7 Usage: $0 COUNT MAXADD. COUNT will determine the amount of numbers printed, and |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
8 MAXADD will limit the value that will be added to each of those numbers. |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
9 """ |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
10 |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
11 from __future__ import print_function |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
12 |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
13 import random |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
14 import sys |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
15 |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
16 def main(): |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
17 count = int(sys.argv[1]) |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
18 maxadd = int(sys.argv[2]) |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
19 for x in range(count): |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
20 print(x + random.randint(0, maxadd)) |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
21 |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
22 if __name__ == '__main__': |
11b8f7003713
tests: move ad-hoc random_rev.py to testlib/random-revs.py
Anton Shestakov <av6@dwimlabs.net>
parents:
diff
changeset
|
23 main() |