Skip to content

Commit 621d228

Browse files
committed
feat: Newer python versions; new test, few improvements
1 parent 35a3291 commit 621d228

File tree

11 files changed

+144
-31
lines changed

11 files changed

+144
-31
lines changed

.vscode/launch.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python Debugger: Current File",
9+
"type": "debugpy",
10+
"request": "launch",
11+
"program": "${file}",
12+
"console": "integratedTerminal"
13+
}
14+
]
15+
}

docker-compose.yml

+61-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,22 @@ services:
1212
environment:
1313
POSTGRES_DB: benchmark
1414
POSTGRES_PASSWORD: password
15+
deploy:
16+
resources:
17+
limits:
18+
cpus: "0.25"
19+
memory: 100M
1520
dummy_start:
1621
image: alpine:latest
1722
command: sleep 5
1823
depends_on:
1924
postgres:
2025
condition: service_started
26+
deploy:
27+
resources:
28+
limits:
29+
cpus: "0.1"
30+
memory: 50M
2131
python36:
2232
build:
2333
context: ./docker/
@@ -33,6 +43,11 @@ services:
3343
volumes:
3444
- ./src:/code/src
3545
- ./report:/code/report
46+
deploy:
47+
resources:
48+
limits:
49+
cpus: "0.75"
50+
memory: 350M
3651
depends_on:
3752
dummy_start:
3853
condition: service_completed_successfully
@@ -50,6 +65,11 @@ services:
5065
volumes:
5166
- ./src:/code/src
5267
- ./report:/code/report
68+
deploy:
69+
resources:
70+
limits:
71+
cpus: "0.75"
72+
memory: 350M
5373
depends_on:
5474
postgres:
5575
condition: service_started
@@ -59,13 +79,18 @@ services:
5979
build:
6080
context: ./docker/
6181
args:
62-
DOCKER_IMAGE: python:3.8.19-slim-bookworm
82+
DOCKER_IMAGE: python:3.8.20-slim-bookworm
6383
entrypoint: ./entrypoint.sh
6484
environment:
6585
- PY_VERSION=3.8
6686
volumes:
6787
- ./src:/code/src
6888
- ./report:/code/report
89+
deploy:
90+
resources:
91+
limits:
92+
cpus: "0.75"
93+
memory: 350M
6994
depends_on:
7095
postgres:
7196
condition: service_started
@@ -75,13 +100,18 @@ services:
75100
build:
76101
context: ./docker/
77102
args:
78-
DOCKER_IMAGE: python:3.9.19-slim-bookworm
103+
DOCKER_IMAGE: python:3.9.20-slim-bookworm
79104
entrypoint: ./entrypoint.sh
80105
environment:
81106
- PY_VERSION=3.9
82107
volumes:
83108
- ./src:/code/src
84109
- ./report:/code/report
110+
deploy:
111+
resources:
112+
limits:
113+
cpus: "0.75"
114+
memory: 350M
85115
depends_on:
86116
postgres:
87117
condition: service_started
@@ -91,13 +121,18 @@ services:
91121
build:
92122
context: ./docker/
93123
args:
94-
DOCKER_IMAGE: python:3.10.14-slim-bookworm
124+
DOCKER_IMAGE: python:3.10.15-slim-bookworm
95125
entrypoint: ./entrypoint.sh
96126
environment:
97127
- PY_VERSION=3.10
98128
volumes:
99129
- ./src:/code/src
100130
- ./report:/code/report
131+
deploy:
132+
resources:
133+
limits:
134+
cpus: "0.75"
135+
memory: 350M
101136
depends_on:
102137
postgres:
103138
condition: service_started
@@ -107,13 +142,18 @@ services:
107142
build:
108143
context: ./docker/
109144
args:
110-
DOCKER_IMAGE: python:3.11.9-slim-bookworm
145+
DOCKER_IMAGE: python:3.11.10-slim-bookworm
111146
entrypoint: ./entrypoint.sh
112147
environment:
113148
- PY_VERSION=3.11
114149
volumes:
115150
- ./src:/code/src
116151
- ./report:/code/report
152+
deploy:
153+
resources:
154+
limits:
155+
cpus: "0.75"
156+
memory: 350M
117157
depends_on:
118158
postgres:
119159
condition: service_started
@@ -123,7 +163,7 @@ services:
123163
build:
124164
context: ./docker/
125165
args:
126-
DOCKER_IMAGE: python:3.12.3-slim-bookworm
166+
DOCKER_IMAGE: python:3.12.6-slim-bookworm
127167
SETUPTOOLS_VERSION: 68.2.2
128168
REQUIREMENTS: requirements312.txt
129169
entrypoint: ./entrypoint.sh
@@ -132,6 +172,11 @@ services:
132172
volumes:
133173
- ./src:/code/src
134174
- ./report:/code/report
175+
deploy:
176+
resources:
177+
limits:
178+
cpus: "0.75"
179+
memory: 350M
135180
depends_on:
136181
postgres:
137182
condition: service_started
@@ -141,7 +186,7 @@ services:
141186
build:
142187
context: ./docker/
143188
args:
144-
DOCKER_IMAGE: python:3.13.0b2-slim-bookworm
189+
DOCKER_IMAGE: python:3.13.0rc2-slim-bookworm
145190
SETUPTOOLS_VERSION: 68.2.2
146191
REQUIREMENTS: requirements313.txt
147192
entrypoint: ./entrypoint.sh
@@ -150,6 +195,11 @@ services:
150195
volumes:
151196
- ./src:/code/src
152197
- ./report:/code/report
198+
deploy:
199+
resources:
200+
limits:
201+
cpus: "0.75"
202+
memory: 350M
153203
depends_on:
154204
postgres:
155205
condition: service_started
@@ -158,6 +208,11 @@ services:
158208
dummy_close:
159209
image: alpine:latest
160210
command: sleep 2
211+
deploy:
212+
resources:
213+
limits:
214+
cpus: "0.1"
215+
memory: 50M
161216
depends_on:
162217
postgres:
163218
condition: service_started

src/support/template.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ This is a simple repo to validate and test any (almost any) python program again
44

55
- Python 3.6.15
66
- Python 3.7.17
7-
- Python 3.8.19
8-
- Python 3.9.19
9-
- Python 3.10.14
10-
- Python 3.11.9
11-
- Python 3.12.3
12-
- Python 3.13.0b2
7+
- Python 3.8.20
8+
- Python 3.9.20
9+
- Python 3.10.15
10+
- Python 3.11.10
11+
- Python 3.12.6
12+
- Python 3.13.0rc2
1313

1414
## Should i care about it
1515

src/tests/complex/classes/classes.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# @ALLOWED_VERSIONS: 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13
22

3+
from random import choice, randint
4+
35

46
class Person:
57
def __init__(self, name, age) -> None:
@@ -14,7 +16,8 @@ def __repr__(self) -> str:
1416

1517

1618
def main():
17-
persons = [Person("Rodolfo", 40) for _ in range(20_000)]
19+
names = ("Rodolfo", "John", "Jane", "Doe", "Alice", "Bob", "Charlie", "David", "Eve", "Frank")
20+
persons = [Person(**{"name": choice(names), "age": randint(18, 65)}) for _ in range(20_000)]
1821
for person in persons:
1922
name, age = person.name, person.age
2023
return 0

src/tests/complex/classes/dataclasses_.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# @ALLOWED_VERSIONS: 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13
22

33
from dataclasses import dataclass
4+
from random import choice, randint
45

56

67
@dataclass
@@ -10,7 +11,8 @@ class Person:
1011

1112

1213
def main():
13-
persons = [Person("Rodolfo", 40) for _ in range(20_000)]
14+
names = ("Rodolfo", "John", "Jane", "Doe", "Alice", "Bob", "Charlie", "David", "Eve", "Frank")
15+
persons = [Person(**{"name": choice(names), "age": randint(18, 65)}) for _ in range(20_000)]
1416
for person in persons:
1517
name, age = person.name, person.age
1618
return 0

src/tests/complex/classes/namedtuple_classes.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# @ALLOWED_VERSIONS: 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13
22

3+
from random import choice, randint
34
from typing import NamedTuple
45

56

@@ -15,7 +16,8 @@ def __repr__(self) -> str:
1516

1617

1718
def main():
18-
persons = [Person("Rodolfo", 40) for _ in range(20_000)]
19+
names = ("Rodolfo", "John", "Jane", "Doe", "Alice", "Bob", "Charlie", "David", "Eve", "Frank")
20+
persons = [Person(**{"name": choice(names), "age": randint(18, 65)}) for _ in range(20_000)]
1921
for person in persons:
2022
name, age = person.name, person.age
2123
return 0

src/tests/complex/classes/simplenamespace.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# @ALLOWED_VERSIONS: 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13
22

3+
from random import choice, randint
34
from types import SimpleNamespace
45

56

7+
class Person(SimpleNamespace): ...
8+
9+
610
def main():
7-
persons = [SimpleNamespace(**{"name": "Rodolfo", "age": 39}) for _ in range(20_000)]
11+
names = ("Rodolfo", "John", "Jane", "Doe", "Alice", "Bob", "Charlie", "David", "Eve", "Frank")
12+
persons = [Person(**{"name": choice(names), "age": randint(18, 65)}) for _ in range(20_000)]
813
for person in persons:
914
name, age = person.name, person.age
1015
return 0

src/tests/complex/classes/sloted_classes.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# @ALLOWED_VERSIONS: 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13
22

33

4+
from random import choice, randint
5+
6+
47
class Person:
58
__slotst__ = ("name", "age")
69

@@ -16,7 +19,8 @@ def __repr__(self) -> str:
1619

1720

1821
def main():
19-
persons = [Person("Rodolfo", 40) for _ in range(20_000)]
22+
names = ("Rodolfo", "John", "Jane", "Doe", "Alice", "Bob", "Charlie", "David", "Eve", "Frank")
23+
persons = [Person(**{"name": choice(names), "age": randint(18, 65)}) for _ in range(20_000)]
2024
for person in persons:
2125
name, age = person.name, person.age
2226
return 0

src/tests/modules/enum/enum_lookup.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# @ALLOWED_VERSIONS: 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13
2+
3+
from enum import Enum
4+
from random import choices, randint
5+
from string import ascii_letters
6+
from typing import Dict, List
7+
8+
9+
class AccountTypeId(Enum):
10+
Admin = "".join(choices(ascii_letters, k=16))
11+
Business = "".join(choices(ascii_letters, k=16))
12+
Developer = "".join(choices(ascii_letters, k=16))
13+
Support = "".join(choices(ascii_letters, k=16))
14+
Guest = "".join(choices(ascii_letters, k=16))
15+
Manager = "".join(choices(ascii_letters, k=16))
16+
17+
18+
def get_account_type_id(user_id: str, account_types: str) -> List[Dict[str, str]]:
19+
return [
20+
{"user_id": user_id, "account_type_id": getattr(AccountTypeId, acc_type).value}
21+
for acc_type in account_types.split(";")
22+
]
23+
24+
25+
def main():
26+
account_options = [k for k, v in AccountTypeId.__members__.items()]
27+
for _ in range(20_000):
28+
user_id = "".join(choices(ascii_letters, k=15))
29+
accounts = choices(account_options, k=randint(1, 3))
30+
assert get_account_type_id(user_id, ";".join(accounts)) == [
31+
{"user_id": user_id, "account_type_id": getattr(AccountTypeId, acc).value} for acc in accounts
32+
]
33+
return 0
34+
35+
36+
if __name__ == "__main__":
37+
raise SystemExit(main())

src/tests/modules/json/json_module.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44
from json import dumps, loads
55
from random import choice, randint
66

7-
NAMES = (
8-
"Rodolfo",
9-
"Sthefany",
10-
"Larissa",
11-
"Rodrigo",
12-
)
7+
NAMES = ("Rodolfo", "John", "Jane", "Doe", "Alice", "Bob", "Charlie", "David", "Eve", "Frank")
138

149

1510
def main():
@@ -18,7 +13,7 @@ def main():
1813
dumped = dumps(
1914
{
2015
"name": choice(names),
21-
"age": randint(5, 75),
16+
"age": randint(18, 65),
2217
"city": "Sao Paulo",
2318
"datetime": datetime.now().isoformat(),
2419
}

src/tests/modules/json/orjson_module.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55

66
from orjson import dumps, loads
77

8-
NAMES = (
9-
"Rodolfo",
10-
"Sthefany",
11-
"Larissa",
12-
"Rodrigo",
13-
)
8+
NAMES = ("Rodolfo", "John", "Jane", "Doe", "Alice", "Bob", "Charlie", "David", "Eve", "Frank")
149

1510

1611
def main():
@@ -19,7 +14,7 @@ def main():
1914
dumped = dumps(
2015
{
2116
"name": choice(names),
22-
"age": randint(5, 75),
17+
"age": randint(18, 65),
2318
"city": "Sao Paulo",
2419
"datetime": datetime.now().isoformat(),
2520
}

0 commit comments

Comments
 (0)