|
40 | 40 | from typing import Any, Callable, ClassVar, Literal, Pattern, Match, ParamSpec, TypeVar |
41 | 41 | from pydantic import ValidationError |
42 | 42 |
|
| 43 | +random.seed(42) |
| 44 | + |
43 | 45 | log = logging.getLogger(__name__) |
44 | 46 |
|
45 | 47 | Verdict = Literal['AC', 'TLE', 'OLE', 'MLE', 'RTE', 'WA', 'PAC', 'JE'] |
@@ -1017,11 +1019,11 @@ def __str__(self) -> str: |
1017 | 1019 | # Junk data. The validator should reject these cases |
1018 | 1020 | _JUNK_CASES = [ |
1019 | 1021 | ('an empty file', b''), |
1020 | | - ('a binary file with random bytes', bytearray(random.Random(0).randbytes(1024))), |
| 1022 | + ('a binary file with random bytes', bytearray(random.Random(42).randbytes(1024))), |
1021 | 1023 | ('a text file with the ASCII characters 32 up to 127', bytearray(x for x in range(32, 127))), |
1022 | 1024 | ( |
1023 | 1025 | 'a random text file with printable ASCII characters', |
1024 | | - bytearray(random.choice(string.printable.encode('utf8')) for _ in range(200)), |
| 1026 | + (lambda rng: bytearray(rng.choice(string.printable.encode('utf8')) for _ in range(200)))(random.Random(42)), |
1025 | 1027 | ), |
1026 | 1028 | ] |
1027 | 1029 |
|
@@ -1058,11 +1060,9 @@ def _build_junk_modifier( |
1058 | 1060 |
|
1059 | 1061 |
|
1060 | 1062 | _JUNK_MODIFICATIONS = [ |
1061 | | - _build_junk_modifier( |
1062 | | - 'spaces added where there already is whitespace', r'\s', lambda m: m.group(0) + ' ' * random.randint(1, 5) |
1063 | | - ), |
1064 | | - _build_junk_modifier('spaces added to the end of a line', r'\n', lambda m: m.group(0) + ' ' * random.randint(1, 5)), |
1065 | | - _build_junk_modifier('newlines added where there already are newlines', '\n', lambda m: '\n' * random.randint(2, 5)), |
| 1063 | + _build_junk_modifier('spaces added where there already is whitespace', r'\s', lambda m: m.group(0) + ' '), |
| 1064 | + _build_junk_modifier('spaces added to the end of a line', r'\n', lambda m: m.group(0) + ' '), |
| 1065 | + _build_junk_modifier('newlines added where there already are newlines', '\n', lambda m: '\n\n'), |
1066 | 1066 | _build_junk_modifier('leading zeros added to integers', r'(^|[^.]\b)([0-9]+)\b', r'\g<1>0000000000\g<2>'), |
1067 | 1067 | _build_junk_modifier('trailing zeros added to real number decimal portion', r'\.[0-9]+\b', r'\g<0>0000000000'), |
1068 | 1068 | ( |
|
0 commit comments