Browse Source

ref: fix devenv tools tests in ci (#54289)

tools intentionally doens't have access to sentry deps
anthony sottile 1 year ago
parent
commit
9b533ba9af

+ 2 - 2
.github/workflows/development-environment.yml

@@ -9,8 +9,8 @@ on:
       - '.python-version'
       - '.envrc'
       - 'Brewfile'
-      - 'scripts/*'
-      - 'tools/*'
+      - 'scripts/**'
+      - 'tools/**'
       - 'src/sentry/runner/commands/devserver.py'
       - 'src/sentry/runner/commands/devservices.py'
       - 'bin/load-mocks'

+ 6 - 16
tests/tools/mypy_helpers/test_plugin.py

@@ -225,25 +225,15 @@ Found 4 errors in 1 file (checked 1 source file)
 
 
 @pytest.mark.parametrize(
-    ("attr", "modname"),
+    "attr",
     (
-        ("access", "sentry.api.base"),
-        ("csp_nonce", "csp.middleware"),
-        ("is_sudo", "sudo.middleware"),
-        ("subdomain", "sentry.middleware.subdomain"),
+        pytest.param("access", id="access from sentry.api.base"),
+        pytest.param("csp_nonce", id="csp_nonce from csp.middleware"),
+        pytest.param("is_sudo", id="is_sudo from sudo.middleware"),
+        pytest.param("subdomain", id="subdomain from sentry.middleware.subdomain"),
     ),
 )
-def test_added_http_request_attribute(attr: str, modname: str) -> None:
-    mod = __import__(modname, fromlist=["_trash"])
-    assert mod.__file__ is not None
-    with open(mod.__file__) as f:
-        if f"request.{attr} =" not in f.read():
-            raise AssertionError(
-                f"expected a `request.{attr} = ` monkeypatch "
-                f"in {modname} ({mod.__file__})!\n\n"
-                f"perhaps the mypy plug for this can be removed?"
-            )
-
+def test_added_http_request_attribute(attr: str) -> None:
     src = f"""\
 from django.http.request import HttpRequest
 x: HttpRequest