prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Run Pytest tests in parallel
  https://meltano.slack.com/archives/CKHP6G5V4/p1653508630941889
  
  Looks like pytest doesn't take 45 minutes, not sure why I though it was taking that long before? Maybe on gitlab CI updated the title to reflect that it takes ~5-10 minutes to run pytest today. 
  
  1. Be sure https://github.com/meltano/meltano/pull/6155/files#diff-65c008e1065903299dfa0da25e1f18d0f87f387867ccbbf2b0888eb138bdb255L242 is implemented (This uses a seperate folder for each Test in your temp directory instead of the same folder over and over again)
  1. `poetry add -D pytest-xdist==1.*`
  1. `poetry run pytest -n 20` 
  1. Watch tests run extremely quickly
  
  There's still a large number of failures here as some tests depend on the other I believe? Not exactly sure what causes the failures, but it's clear they weren't all designed with parallel testing in mind.  The gain is big enough it may be worth the time to figure out what causes the failures. 
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `noxfile.py`
  Content:
  ```
  1 """Nox configuration."""
  2 
  3 from __future__ import annotations
  4 
  5 import os
  6 import sys
  7 from pathlib import Path
  8 from random import randint
  9 from textwrap import dedent
  10 
  11 try:
  12     from nox_poetry import Session
  13     from nox_poetry import session as nox_session
  14 except ImportError:
  15     message = f"""\
  16     Nox failed to import the 'nox-poetry' package.
  17     Please install it using the following command:
  18     {sys.executable} -m pip install nox-poetry"""
  19     raise SystemExit(dedent(message)) from None
  20 
  21 
  22 package = "meltano"
  23 python_versions = ["3.10", "3.9", "3.8", "3.7"]
  24 main_python_version = "3.9"
  25 locations = "src", "tests", "noxfile.py"
  26 
  27 
  28 @nox_session(python=python_versions)
  29 def tests(session: Session) -> None:
  30     """Execute pytest tests and compute coverage.
  31 
  32     Args:
  33         session: Nox session.
  34     """
  35     backend_db = os.environ.get("PYTEST_BACKEND", "sqlite")
  36 
  37     if backend_db == "mssql":
  38         session.install(".[mssql]")
  39     else:
  40         session.install(".")
  41 
  42     session.install(
  43         "coverage[toml]",
  44         "freezegun",
  45         "mock",
  46         "pytest",
  47         "pytest-asyncio",
  48         "pytest-docker",
  49         "pytest-order",
  50         "pytest-randomly",
  51         "requests-mock",
  52     )
  53 
  54     try:
  55         session.run(
  56             "coverage",
  57             "run",
  58             "--parallel",
  59             "-m",
  60             "pytest",
  61             f"--randomly-seed={randint(0, 2**32-1)}",  # noqa: S311, WPS432
  62             *session.posargs,
  63             env={"NOX_CURRENT_SESSION": "tests"},
  64         )
  65     finally:
  66         if session.interactive:
  67             session.notify("coverage", posargs=[])
  68 
  69 
  70 @nox_session(python=main_python_version)
  71 def coverage(session: Session) -> None:
  72     """Upload coverage data.
  73 
  74     Args:
  75         session: Nox session.
  76     """
  77     args = session.posargs or ["report"]
  78 
  79     session.install("coverage[toml]")
  80 
  81     if not session.posargs and any(Path().glob(".coverage.*")):
  82         session.run("coverage", "combine")
  83 
  84     session.run("coverage", *args)
  85 
  86 
  87 @nox_session(python=main_python_version)
  88 def mypy(session: Session) -> None:
  89     """Run mypy type checking.
  90 
  91     Args:
  92         session: Nox session.
  93     """
  94     args = session.posargs or ["src/meltano"]
  95 
  96     session.install(".")
  97     session.install(
  98         "mypy",
  99         "sqlalchemy2-stubs",
  100         "types-requests",
  101     )
  102     session.run("mypy", *args)
  103
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/noxfile.py b/noxfile.py
  --- a/noxfile.py
  +++ b/noxfile.py
  @@ -40,23 +40,20 @@
           session.install(".")
   
       session.install(
  -        "coverage[toml]",
           "freezegun",
           "mock",
           "pytest",
           "pytest-asyncio",
  +        "pytest-cov",
           "pytest-docker",
           "pytest-order",
           "pytest-randomly",
  +        "pytest-xdist",
           "requests-mock",
       )
   
       try:
           session.run(
  -            "coverage",
  -            "run",
  -            "--parallel",
  -            "-m",
               "pytest",
               f"--randomly-seed={randint(0, 2**32-1)}",  # noqa: S311, WPS432
               *session.posargs,
  
verification_info: {"golden_diff": "diff --git a/noxfile.py b/noxfile.py\n--- a/noxfile.py\n+++ b/noxfile.py\n@@ -40,23 +40,20 @@\n         session.install(\".\")\n \n     session.install(\n-        \"coverage[toml]\",\n         \"freezegun\",\n         \"mock\",\n         \"pytest\",\n         \"pytest-asyncio\",\n+        \"pytest-cov\",\n         \"pytest-docker\",\n         \"pytest-order\",\n         \"pytest-randomly\",\n+        \"pytest-xdist\",\n         \"requests-mock\",\n     )\n \n     try:\n         session.run(\n-            \"coverage\",\n-            \"run\",\n-            \"--parallel\",\n-            \"-m\",\n             \"pytest\",\n             f\"--randomly-seed={randint(0, 2**32-1)}\",  # noqa: S311, WPS432\n             *session.posargs,\n", "issue": "Run Pytest tests in parallel\nhttps://meltano.slack.com/archives/CKHP6G5V4/p1653508630941889\r\n\r\nLooks like pytest doesn't take 45 minutes, not sure why I though it was taking that long before? Maybe on gitlab CI updated the title to reflect that it takes ~5-10 minutes to run pytest today. \r\n\r\n1. Be sure https://github.com/meltano/meltano/pull/6155/files#diff-65c008e1065903299dfa0da25e1f18d0f87f387867ccbbf2b0888eb138bdb255L242 is implemented (This uses a seperate folder for each Test in your temp directory instead of the same folder over and over again)\r\n1. `poetry add -D pytest-xdist==1.*`\r\n1. `poetry run pytest -n 20` \r\n1. Watch tests run extremely quickly\r\n\r\nThere's still a large number of failures here as some tests depend on the other I believe? Not exactly sure what causes the failures, but it's clear they weren't all designed with parallel testing in mind.  The gain is big enough it may be worth the time to figure out what causes the failures. \r\n\r\n\n", "before_files": [{"content": "\"\"\"Nox configuration.\"\"\"\n\nfrom __future__ import annotations\n\nimport os\nimport sys\nfrom pathlib import Path\nfrom random import randint\nfrom textwrap import dedent\n\ntry:\n    from nox_poetry import Session\n    from nox_poetry import session as nox_session\nexcept ImportError:\n    message = f\"\"\"\\\n    Nox failed to import the 'nox-poetry' package.\n    Please install it using the following command:\n    {sys.executable} -m pip install nox-poetry\"\"\"\n    raise SystemExit(dedent(message)) from None\n\n\npackage = \"meltano\"\npython_versions = [\"3.10\", \"3.9\", \"3.8\", \"3.7\"]\nmain_python_version = \"3.9\"\nlocations = \"src\", \"tests\", \"noxfile.py\"\n\n\n@nox_session(python=python_versions)\ndef tests(session: Session) -> None:\n    \"\"\"Execute pytest tests and compute coverage.\n\n    Args:\n        session: Nox session.\n    \"\"\"\n    backend_db = os.environ.get(\"PYTEST_BACKEND\", \"sqlite\")\n\n    if backend_db == \"mssql\":\n        session.install(\".[mssql]\")\n    else:\n        session.install(\".\")\n\n    session.install(\n        \"coverage[toml]\",\n        \"freezegun\",\n        \"mock\",\n        \"pytest\",\n        \"pytest-asyncio\",\n        \"pytest-docker\",\n        \"pytest-order\",\n        \"pytest-randomly\",\n        \"requests-mock\",\n    )\n\n    try:\n        session.run(\n            \"coverage\",\n            \"run\",\n            \"--parallel\",\n            \"-m\",\n            \"pytest\",\n            f\"--randomly-seed={randint(0, 2**32-1)}\",  # noqa: S311, WPS432\n            *session.posargs,\n            env={\"NOX_CURRENT_SESSION\": \"tests\"},\n        )\n    finally:\n        if session.interactive:\n            session.notify(\"coverage\", posargs=[])\n\n\n@nox_session(python=main_python_version)\ndef coverage(session: Session) -> None:\n    \"\"\"Upload coverage data.\n\n    Args:\n        session: Nox session.\n    \"\"\"\n    args = session.posargs or [\"report\"]\n\n    session.install(\"coverage[toml]\")\n\n    if not session.posargs and any(Path().glob(\".coverage.*\")):\n        session.run(\"coverage\", \"combine\")\n\n    session.run(\"coverage\", *args)\n\n\n@nox_session(python=main_python_version)\ndef mypy(session: Session) -> None:\n    \"\"\"Run mypy type checking.\n\n    Args:\n        session: Nox session.\n    \"\"\"\n    args = session.posargs or [\"src/meltano\"]\n\n    session.install(\".\")\n    session.install(\n        \"mypy\",\n        \"sqlalchemy2-stubs\",\n        \"types-requests\",\n    )\n    session.run(\"mypy\", *args)\n", "path": "noxfile.py"}], "after_files": [{"content": "\"\"\"Nox configuration.\"\"\"\n\nfrom __future__ import annotations\n\nimport os\nimport sys\nfrom pathlib import Path\nfrom random import randint\nfrom textwrap import dedent\n\ntry:\n    from nox_poetry import Session\n    from nox_poetry import session as nox_session\nexcept ImportError:\n    message = f\"\"\"\\\n    Nox failed to import the 'nox-poetry' package.\n    Please install it using the following command:\n    {sys.executable} -m pip install nox-poetry\"\"\"\n    raise SystemExit(dedent(message)) from None\n\n\npackage = \"meltano\"\npython_versions = [\"3.10\", \"3.9\", \"3.8\", \"3.7\"]\nmain_python_version = \"3.9\"\nlocations = \"src\", \"tests\", \"noxfile.py\"\n\n\n@nox_session(python=python_versions)\ndef tests(session: Session) -> None:\n    \"\"\"Execute pytest tests and compute coverage.\n\n    Args:\n        session: Nox session.\n    \"\"\"\n    backend_db = os.environ.get(\"PYTEST_BACKEND\", \"sqlite\")\n\n    if backend_db == \"mssql\":\n        session.install(\".[mssql]\")\n    else:\n        session.install(\".\")\n\n    session.install(\n        \"freezegun\",\n        \"mock\",\n        \"pytest\",\n        \"pytest-asyncio\",\n        \"pytest-cov\",\n        \"pytest-docker\",\n        \"pytest-order\",\n        \"pytest-randomly\",\n        \"pytest-xdist\",\n        \"requests-mock\",\n    )\n\n    try:\n        session.run(\n            \"pytest\",\n            f\"--randomly-seed={randint(0, 2**32-1)}\",  # noqa: S311, WPS432\n            *session.posargs,\n            env={\"NOX_CURRENT_SESSION\": \"tests\"},\n        )\n    finally:\n        if session.interactive:\n            session.notify(\"coverage\", posargs=[])\n\n\n@nox_session(python=main_python_version)\ndef coverage(session: Session) -> None:\n    \"\"\"Upload coverage data.\n\n    Args:\n        session: Nox session.\n    \"\"\"\n    args = session.posargs or [\"report\"]\n\n    session.install(\"coverage[toml]\")\n\n    if not session.posargs and any(Path().glob(\".coverage.*\")):\n        session.run(\"coverage\", \"combine\")\n\n    session.run(\"coverage\", *args)\n\n\n@nox_session(python=main_python_version)\ndef mypy(session: Session) -> None:\n    \"\"\"Run mypy type checking.\n\n    Args:\n        session: Nox session.\n    \"\"\"\n    args = session.posargs or [\"src/meltano\"]\n\n    session.install(\".\")\n    session.install(\n        \"mypy\",\n        \"sqlalchemy2-stubs\",\n        \"types-requests\",\n    )\n    session.run(\"mypy\", *args)\n", "path": "noxfile.py"}]}