Skip to content

Commit 3a43dc9

Browse files
authored
feat(toxgen): Generate TESTPATH for integrated test suites (#4863)
### Description Make toxgen generate the `TESTPATH` env var for integrated test suites, removing a manual step when adding a new test suite. #### Issues Closes #4536 #### Reminders - Please add tests to validate your changes, and lint your code using `tox -e linters`. - Add GH Issue ID _&_ Linear ID (if applicable) - PR title should use [conventional commit](https://develop.sentry.dev/engineering-practices/commit-messages/#type) style (`feat:`, `fix:`, `ref:`, `meta:`) - For external contributors: [CONTRIBUTING.md](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md), [Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord community](https://discord.gg/Ww9hbqr)
1 parent 77a0a37 commit 3a43dc9

File tree

5 files changed

+39
-68
lines changed

5 files changed

+39
-68
lines changed

scripts/populate_tox/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,4 @@ picked (this doesn't count towards `num_versions`).
207207
"Defining constraints" section for the format.
208208
3. Add the integration to one of the groups in the `GROUPS` dictionary in
209209
`scripts/split_tox_gh_actions/split_tox_gh_actions.py`.
210-
4. Add the `TESTPATH` for the test suite in `tox.jinja`'s `setenv` section.
211-
5. Run `scripts/generate-test-files.sh` and commit the changes.
210+
4. Run `scripts/generate-test-files.sh` and commit the changes.

scripts/populate_tox/populate_tox.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,11 @@ def _render_dependencies(integration: str, releases: list[Version]) -> list[str]
513513
def write_tox_file(packages: dict) -> None:
514514
template = ENV.get_template("tox.jinja")
515515

516-
context = {"groups": {}}
516+
context = {
517+
"groups": {},
518+
"testpaths": [],
519+
}
520+
517521
for group, integrations in packages.items():
518522
context["groups"][group] = []
519523
for integration in integrations:
@@ -528,6 +532,14 @@ def write_tox_file(packages: dict) -> None:
528532
),
529533
}
530534
)
535+
context["testpaths"].append(
536+
(
537+
integration["name"],
538+
f"tests/integrations/{integration['integration_name']}",
539+
)
540+
)
541+
542+
context["testpaths"].sort()
531543

532544
rendered = template.render(context)
533545

@@ -759,6 +771,10 @@ def main(fail_on_changes: bool = False) -> None:
759771
"package": package,
760772
"extra": extra,
761773
"releases": test_releases,
774+
"integration_name": TEST_SUITE_CONFIG[integration].get(
775+
"integration_name"
776+
)
777+
or integration,
762778
}
763779
)
764780

scripts/populate_tox/releases.jsonl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
{"info": {"classifiers": ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7"], "name": "boto3", "requires_python": "", "version": "1.12.49", "yanked": false}}
4747
{"info": {"classifiers": ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9"], "name": "boto3", "requires_python": ">= 3.6", "version": "1.20.54", "yanked": false}}
4848
{"info": {"classifiers": ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9"], "name": "boto3", "requires_python": ">= 3.7", "version": "1.28.85", "yanked": false}}
49-
{"info": {"classifiers": ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", "Programming Language :: Python :: 3.9"], "name": "boto3", "requires_python": ">=3.9", "version": "1.40.37", "yanked": false}}
49+
{"info": {"classifiers": ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", "Programming Language :: Python :: 3.9"], "name": "boto3", "requires_python": ">=3.9", "version": "1.40.38", "yanked": false}}
5050
{"info": {"classifiers": ["Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries", "Topic :: Internet :: WWW/HTTP :: HTTP Servers", "Topic :: Internet :: WWW/HTTP :: WSGI", "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", "Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware", "Topic :: Internet :: WWW/HTTP :: WSGI :: Server", "Topic :: Software Development :: Libraries :: Application Frameworks"], "name": "bottle", "requires_python": "", "version": "0.12.25", "yanked": false}}
5151
{"info": {"classifiers": ["Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries", "Topic :: Internet :: WWW/HTTP :: HTTP Servers", "Topic :: Internet :: WWW/HTTP :: WSGI", "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", "Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware", "Topic :: Internet :: WWW/HTTP :: WSGI :: Server", "Topic :: Software Development :: Libraries :: Application Frameworks"], "name": "bottle", "requires_python": null, "version": "0.13.4", "yanked": false}}
5252
{"info": {"classifiers": ["Development Status :: 5 - Production/Stable", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Object Brokering", "Topic :: System :: Distributed Computing"], "name": "celery", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", "version": "4.4.7", "yanked": false}}

scripts/populate_tox/tox.jinja

Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -136,69 +136,22 @@ setenv =
136136
django: DJANGO_SETTINGS_MODULE=tests.integrations.django.myapp.settings
137137
spark-v{3.0.3,3.5.6}: JAVA_HOME=/usr/lib/jvm/temurin-11-jdk-amd64
138138
139+
# TESTPATH definitions for test suites not managed by toxgen
139140
common: TESTPATH=tests
140141
gevent: TESTPATH=tests
141-
aiohttp: TESTPATH=tests/integrations/aiohttp
142-
anthropic: TESTPATH=tests/integrations/anthropic
143-
ariadne: TESTPATH=tests/integrations/ariadne
144-
arq: TESTPATH=tests/integrations/arq
145142
asgi: TESTPATH=tests/integrations/asgi
146-
asyncpg: TESTPATH=tests/integrations/asyncpg
147143
aws_lambda: TESTPATH=tests/integrations/aws_lambda
148-
beam: TESTPATH=tests/integrations/beam
149-
boto3: TESTPATH=tests/integrations/boto3
150-
bottle: TESTPATH=tests/integrations/bottle
151-
celery: TESTPATH=tests/integrations/celery
152-
chalice: TESTPATH=tests/integrations/chalice
153-
clickhouse_driver: TESTPATH=tests/integrations/clickhouse_driver
154-
cohere: TESTPATH=tests/integrations/cohere
155144
cloud_resource_context: TESTPATH=tests/integrations/cloud_resource_context
156-
django: TESTPATH=tests/integrations/django
157-
dramatiq: TESTPATH=tests/integrations/dramatiq
158-
falcon: TESTPATH=tests/integrations/falcon
159-
fastapi: TESTPATH=tests/integrations/fastapi
160-
flask: TESTPATH=tests/integrations/flask
161145
gcp: TESTPATH=tests/integrations/gcp
162-
gql: TESTPATH=tests/integrations/gql
163-
graphene: TESTPATH=tests/integrations/graphene
164-
grpc: TESTPATH=tests/integrations/grpc
165-
httpx: TESTPATH=tests/integrations/httpx
166-
huey: TESTPATH=tests/integrations/huey
167-
huggingface_hub: TESTPATH=tests/integrations/huggingface_hub
168-
langchain-base: TESTPATH=tests/integrations/langchain
169-
langchain-notiktoken: TESTPATH=tests/integrations/langchain
170-
langgraph: TESTPATH=tests/integrations/langgraph
171-
launchdarkly: TESTPATH=tests/integrations/launchdarkly
172-
litestar: TESTPATH=tests/integrations/litestar
173-
loguru: TESTPATH=tests/integrations/loguru
174-
openai-base: TESTPATH=tests/integrations/openai
175-
openai-notiktoken: TESTPATH=tests/integrations/openai
176-
openai_agents: TESTPATH=tests/integrations/openai_agents
177-
openfeature: TESTPATH=tests/integrations/openfeature
178146
opentelemetry: TESTPATH=tests/integrations/opentelemetry
179147
potel: TESTPATH=tests/integrations/opentelemetry
180-
pure_eval: TESTPATH=tests/integrations/pure_eval
181-
pymongo: TESTPATH=tests/integrations/pymongo
182-
pyramid: TESTPATH=tests/integrations/pyramid
183-
quart: TESTPATH=tests/integrations/quart
184-
ray: TESTPATH=tests/integrations/ray
185-
redis: TESTPATH=tests/integrations/redis
186-
redis_py_cluster_legacy: TESTPATH=tests/integrations/redis_py_cluster_legacy
187-
requests: TESTPATH=tests/integrations/requests
188-
rq: TESTPATH=tests/integrations/rq
189-
sanic: TESTPATH=tests/integrations/sanic
190-
spark: TESTPATH=tests/integrations/spark
191-
sqlalchemy: TESTPATH=tests/integrations/sqlalchemy
192-
starlette: TESTPATH=tests/integrations/starlette
193-
starlite: TESTPATH=tests/integrations/starlite
194-
statsig: TESTPATH=tests/integrations/statsig
195-
strawberry: TESTPATH=tests/integrations/strawberry
196-
tornado: TESTPATH=tests/integrations/tornado
197-
trytond: TESTPATH=tests/integrations/trytond
198-
typer: TESTPATH=tests/integrations/typer
199-
unleash: TESTPATH=tests/integrations/unleash
200148
socket: TESTPATH=tests/integrations/socket
201149
150+
# These TESTPATH definitions are auto-generated by toxgen
151+
{% for integration, testpath in testpaths %}
152+
{{ integration }}: TESTPATH={{ testpath }}
153+
{% endfor %}
154+
202155
passenv =
203156
SENTRY_PYTHON_TEST_POSTGRES_HOST
204157
SENTRY_PYTHON_TEST_POSTGRES_USER

tox.ini

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ envlist =
9191
{py3.6,py3.7}-boto3-v1.12.49
9292
{py3.6,py3.9,py3.10}-boto3-v1.20.54
9393
{py3.7,py3.11,py3.12}-boto3-v1.28.85
94-
{py3.9,py3.12,py3.13}-boto3-v1.40.37
94+
{py3.9,py3.12,py3.13}-boto3-v1.40.38
9595

9696
{py3.6,py3.7,py3.8}-chalice-v1.16.0
9797
{py3.9,py3.12,py3.13}-chalice-v1.32.0
@@ -396,7 +396,7 @@ deps =
396396
boto3-v1.12.49: boto3==1.12.49
397397
boto3-v1.20.54: boto3==1.20.54
398398
boto3-v1.28.85: boto3==1.28.85
399-
boto3-v1.40.37: boto3==1.40.37
399+
boto3-v1.40.38: boto3==1.40.38
400400
{py3.7,py3.8}-boto3: urllib3<2.0.0
401401

402402
chalice-v1.16.0: chalice==1.16.0
@@ -713,29 +713,35 @@ setenv =
713713
django: DJANGO_SETTINGS_MODULE=tests.integrations.django.myapp.settings
714714
spark-v{3.0.3,3.5.6}: JAVA_HOME=/usr/lib/jvm/temurin-11-jdk-amd64
715715

716+
# TESTPATH definitions for test suites not managed by toxgen
716717
common: TESTPATH=tests
717718
gevent: TESTPATH=tests
719+
asgi: TESTPATH=tests/integrations/asgi
720+
aws_lambda: TESTPATH=tests/integrations/aws_lambda
721+
cloud_resource_context: TESTPATH=tests/integrations/cloud_resource_context
722+
gcp: TESTPATH=tests/integrations/gcp
723+
opentelemetry: TESTPATH=tests/integrations/opentelemetry
724+
potel: TESTPATH=tests/integrations/opentelemetry
725+
socket: TESTPATH=tests/integrations/socket
726+
727+
# These TESTPATH definitions are auto-generated by toxgen
718728
aiohttp: TESTPATH=tests/integrations/aiohttp
719729
anthropic: TESTPATH=tests/integrations/anthropic
720730
ariadne: TESTPATH=tests/integrations/ariadne
721731
arq: TESTPATH=tests/integrations/arq
722-
asgi: TESTPATH=tests/integrations/asgi
723732
asyncpg: TESTPATH=tests/integrations/asyncpg
724-
aws_lambda: TESTPATH=tests/integrations/aws_lambda
725733
beam: TESTPATH=tests/integrations/beam
726734
boto3: TESTPATH=tests/integrations/boto3
727735
bottle: TESTPATH=tests/integrations/bottle
728736
celery: TESTPATH=tests/integrations/celery
729737
chalice: TESTPATH=tests/integrations/chalice
730738
clickhouse_driver: TESTPATH=tests/integrations/clickhouse_driver
731739
cohere: TESTPATH=tests/integrations/cohere
732-
cloud_resource_context: TESTPATH=tests/integrations/cloud_resource_context
733740
django: TESTPATH=tests/integrations/django
734741
dramatiq: TESTPATH=tests/integrations/dramatiq
735742
falcon: TESTPATH=tests/integrations/falcon
736-
fastapi: TESTPATH=tests/integrations/fastapi
743+
fastapi: TESTPATH=tests/integrations/fastapi
737744
flask: TESTPATH=tests/integrations/flask
738-
gcp: TESTPATH=tests/integrations/gcp
739745
gql: TESTPATH=tests/integrations/gql
740746
graphene: TESTPATH=tests/integrations/graphene
741747
grpc: TESTPATH=tests/integrations/grpc
@@ -744,16 +750,14 @@ setenv =
744750
huggingface_hub: TESTPATH=tests/integrations/huggingface_hub
745751
langchain-base: TESTPATH=tests/integrations/langchain
746752
langchain-notiktoken: TESTPATH=tests/integrations/langchain
747-
langgraph: TESTPATH=tests/integrations/langgraph
753+
langgraph: TESTPATH=tests/integrations/langgraph
748754
launchdarkly: TESTPATH=tests/integrations/launchdarkly
749755
litestar: TESTPATH=tests/integrations/litestar
750756
loguru: TESTPATH=tests/integrations/loguru
751757
openai-base: TESTPATH=tests/integrations/openai
752758
openai-notiktoken: TESTPATH=tests/integrations/openai
753759
openai_agents: TESTPATH=tests/integrations/openai_agents
754760
openfeature: TESTPATH=tests/integrations/openfeature
755-
opentelemetry: TESTPATH=tests/integrations/opentelemetry
756-
potel: TESTPATH=tests/integrations/opentelemetry
757761
pure_eval: TESTPATH=tests/integrations/pure_eval
758762
pymongo: TESTPATH=tests/integrations/pymongo
759763
pyramid: TESTPATH=tests/integrations/pyramid
@@ -774,7 +778,6 @@ setenv =
774778
trytond: TESTPATH=tests/integrations/trytond
775779
typer: TESTPATH=tests/integrations/typer
776780
unleash: TESTPATH=tests/integrations/unleash
777-
socket: TESTPATH=tests/integrations/socket
778781

779782
passenv =
780783
SENTRY_PYTHON_TEST_POSTGRES_HOST

0 commit comments

Comments
 (0)