From e52fa6317ed4f46e94c5a6feea111cd5b0a8f2c4 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Fri, 20 Dec 2024 18:56:43 +0200 Subject: [PATCH 01/31] Support the free-threaded build of CPython 3.13 --- .github/workflows/ci-cd.yml | 8 ++++++- pyproject.toml | 7 ++++++ scripts/cibw_before_build.sh | 7 ++++++ yarl/_quoting_c.pyx | 45 ++++++++++++++++++------------------ 4 files changed, 43 insertions(+), 24 deletions(-) create mode 100644 scripts/cibw_before_build.sh diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 5e943f7a9..d12faa016 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -184,6 +184,7 @@ jobs: strategy: matrix: pyver: + - 3.13t - 3.13 - 3.12 - 3.11 @@ -231,7 +232,7 @@ jobs: - name: Setup Python ${{ matrix.pyver }} id: python-install - uses: actions/setup-python@v5 + uses: quansight-labs/setup-python@v5 with: python-version: ${{ matrix.pyver }} allow-prereleases: true @@ -241,6 +242,11 @@ jobs: uses: py-actions/py-dependency-install@v4 with: path: requirements/test.txt + - name: Install Cython nightly on free-threading + if: matrix.pyver == '3.13t' + run: | + python -m pip uninstall -y cython + python -m pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple cython - name: Determine pre-compiled compatible wheel env: # NOTE: When `pip` is forced to colorize output piped into `jq`, diff --git a/pyproject.toml b/pyproject.toml index 81900af58..3de49d52b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,6 +49,7 @@ keep-going = false embedsignature = "True" emit_code_comments = "True" linetrace = "True" # Implies `profile=True` +freethreading_compatible = "True" [tool.local.cythonize.kwargs.compile-time-env] # This section can contain compile time env vars @@ -64,6 +65,7 @@ linetrace = "True" # Implies `profile=True` [tool.cibuildwheel] build-frontend = "build" +enable = ["cpython-freethreading"] before-test = [ # NOTE: Attempt to have pip pre-compile PyYAML wheel with our build # NOTE: constraints unset. The hope is that pip will cache that wheel @@ -91,3 +93,8 @@ pure-python = "false" [tool.cibuildwheel.windows] before-test = [] # Windows cmd has different syntax and pip chooses wheels + +[[tool.cibuildwheel.overrides]] +select = "cp313t-*" +build-frontend = "build; --no-isolation" +before-build = "bash {package}/scripts/cibw_before_build.sh" diff --git a/scripts/cibw_before_build.sh b/scripts/cibw_before_build.sh new file mode 100644 index 000000000..718d89d7d --- /dev/null +++ b/scripts/cibw_before_build.sh @@ -0,0 +1,7 @@ +# TODO: Delete when there's a PyPI Cython release (3.1.0) that supports free-threaded Python 3.13. +FREE_THREADED_BUILD="$(python -c"import sysconfig; print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')))")" +if [[ $FREE_THREADED_BUILD == "True" ]]; then + python -m pip install -U pip + python -m pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple cython + python -m pip install setuptools expandvars +fi diff --git a/yarl/_quoting_c.pyx b/yarl/_quoting_c.pyx index 067ba96e4..2d8c6e403 100644 --- a/yarl/_quoting_c.pyx +++ b/yarl/_quoting_c.pyx @@ -25,7 +25,6 @@ cdef str ALLOWED = UNRESERVED + SUB_DELIMS_WITHOUT_QS cdef str QS = '+&=;' DEF BUF_SIZE = 8 * 1024 # 8KiB -cdef char BUFFER[BUF_SIZE] cdef inline Py_UCS4 _to_hex(uint8_t v) noexcept: if v < 10: @@ -49,14 +48,14 @@ cdef inline int _is_lower_hex(Py_UCS4 v) noexcept: return 'a' <= v <= 'f' -cdef inline Py_UCS4 _restore_ch(Py_UCS4 d1, Py_UCS4 d2): +cdef inline long _restore_ch(Py_UCS4 d1, Py_UCS4 d2): cdef int digit1 = _from_hex(d1) if digit1 < 0: - return -1 + return -1 cdef int digit2 = _from_hex(d2) if digit2 < 0: - return -1 - return (digit1 << 4 | digit2) + return -1 + return digit1 << 4 | digit2 cdef uint8_t ALLOWED_TABLE[16] @@ -91,15 +90,18 @@ cdef struct Writer: cdef inline void _init_writer(Writer* writer): - writer.buf = &BUFFER[0] + cdef char *buf = PyMem_Malloc(BUF_SIZE) + if buf == NULL: + PyErr_NoMemory() + return + writer.buf = buf writer.size = BUF_SIZE writer.pos = 0 writer.changed = 0 cdef inline void _release_writer(Writer* writer): - if writer.buf != BUFFER: - PyMem_Free(writer.buf) + PyMem_Free(writer.buf) cdef inline int _write_char(Writer* writer, Py_UCS4 ch, bint changed): @@ -109,17 +111,10 @@ cdef inline int _write_char(Writer* writer, Py_UCS4 ch, bint changed): if writer.pos == writer.size: # reallocate size = writer.size + BUF_SIZE - if writer.buf == BUFFER: - buf = PyMem_Malloc(size) - if buf == NULL: - PyErr_NoMemory() - return -1 - memcpy(buf, writer.buf, writer.size) - else: - buf = PyMem_Realloc(writer.buf, size) - if buf == NULL: - PyErr_NoMemory() - return -1 + buf = PyMem_Realloc(writer.buf, size) + if buf == NULL: + PyErr_NoMemory() + return -1 writer.buf = buf writer.size = size writer.buf[writer.pos] = ch @@ -255,6 +250,7 @@ cdef class _Quoter: Writer *writer ): cdef Py_UCS4 ch + cdef long chl cdef int changed cdef Py_ssize_t idx = 0 @@ -262,11 +258,12 @@ cdef class _Quoter: ch = PyUnicode_READ(kind, data, idx) idx += 1 if ch == '%' and self._requote and idx <= length - 2: - ch = _restore_ch( + chl = _restore_ch( PyUnicode_READ(kind, data, idx), PyUnicode_READ(kind, data, idx + 1) ) - if ch != -1: + if chl != -1: + ch = chl idx += 2 if ch < 128: if bit_at(self._protected_table, ch): @@ -342,6 +339,7 @@ cdef class _Unquoter: cdef Py_ssize_t consumed cdef str unquoted cdef Py_UCS4 ch = 0 + cdef long chl = 0 cdef Py_ssize_t idx = 0 cdef Py_ssize_t start_pct cdef int kind = PyUnicode_KIND(val) @@ -352,11 +350,12 @@ cdef class _Unquoter: idx += 1 if ch == '%' and idx <= length - 2: changed = 1 - ch = _restore_ch( + chl = _restore_ch( PyUnicode_READ(kind, data, idx), PyUnicode_READ(kind, data, idx + 1) ) - if ch != -1: + if chl != -1: + ch = chl idx += 2 assert buflen < 4 buffer[buflen] = ch From 635b9cacfa56eb0e9a045aa92a4d65e9a80a0ee5 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Fri, 20 Dec 2024 19:01:23 +0200 Subject: [PATCH 02/31] Add news fragments --- CHANGES/1456.feature.rst | 1 + CHANGES/1456.packaging.rst | 1 + 2 files changed, 2 insertions(+) create mode 100644 CHANGES/1456.feature.rst create mode 100644 CHANGES/1456.packaging.rst diff --git a/CHANGES/1456.feature.rst b/CHANGES/1456.feature.rst new file mode 100644 index 000000000..c5da0e048 --- /dev/null +++ b/CHANGES/1456.feature.rst @@ -0,0 +1 @@ +Implemented support for the free-threaded build of CPython 3.13 -- by :user:`lysnikolaou`. diff --git a/CHANGES/1456.packaging.rst b/CHANGES/1456.packaging.rst new file mode 100644 index 000000000..911a78b2c --- /dev/null +++ b/CHANGES/1456.packaging.rst @@ -0,0 +1 @@ +Started building wheels for the free-threaded build of CPython 3.13 -- by :user:`lysnikolaou`. From 3aca3a17ae583d43dcd3662384d053fa060e9655 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Fri, 20 Dec 2024 19:20:07 +0200 Subject: [PATCH 03/31] Fix cibuildwheel and cython configs --- pyproject.toml | 3 +-- yarl/_quoting_c.pyx | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3de49d52b..097ffda6e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,6 @@ keep-going = false embedsignature = "True" emit_code_comments = "True" linetrace = "True" # Implies `profile=True` -freethreading_compatible = "True" [tool.local.cythonize.kwargs.compile-time-env] # This section can contain compile time env vars @@ -96,5 +95,5 @@ before-test = [] # Windows cmd has different syntax and pip chooses wheels [[tool.cibuildwheel.overrides]] select = "cp313t-*" -build-frontend = "build; --no-isolation" +build-frontend = "build; args: --no-isolation" before-build = "bash {package}/scripts/cibw_before_build.sh" diff --git a/yarl/_quoting_c.pyx b/yarl/_quoting_c.pyx index 2d8c6e403..6fed3926f 100644 --- a/yarl/_quoting_c.pyx +++ b/yarl/_quoting_c.pyx @@ -1,4 +1,4 @@ -# cython: language_level=3 +# cython: language_level=3, freethreading_compatible=True from cpython.exc cimport PyErr_NoMemory from cpython.mem cimport PyMem_Free, PyMem_Malloc, PyMem_Realloc From f273a6be9441c46c731466c71782868479596a2c Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Fri, 20 Dec 2024 20:01:19 +0200 Subject: [PATCH 04/31] Fix cibuildwheel and linter --- .github/workflows/ci-cd.yml | 5 ++++- MANIFEST.in | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index d12faa016..9a3b953dd 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -246,7 +246,10 @@ jobs: if: matrix.pyver == '3.13t' run: | python -m pip uninstall -y cython - python -m pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple cython + python -m pip install cython \ + --pre \ + --extra-index-url \ + https://pypi.anaconda.org/scientific-python-nightly-wheels/simple - name: Determine pre-compiled compatible wheel env: # NOTE: When `pip` is forced to colorize output piped into `jq`, diff --git a/MANIFEST.in b/MANIFEST.in index 904cf6889..6bb7eb82f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -12,6 +12,7 @@ graft docs graft CHANGES graft requirements graft tests +graft scripts global-exclude *.pyc global-exclude *.cache exclude yarl/*.c From 4ce41638497090e934dd40f06487ab3782ccb8c4 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Fri, 20 Dec 2024 20:09:55 +0200 Subject: [PATCH 05/31] Fix PYTHON_LATEST env var in github actions --- .github/workflows/ci-cd.yml | 2 +- .github/workflows/reusable-linters.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 9a3b953dd..4f6113433 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -38,7 +38,7 @@ env: PY_COLORS: 1 # Recognized by the `py` package, dependency of `pytest` PYTHONIOENCODING: utf-8 PYTHONUTF8: 1 - PYTHON_LATEST: 3.12 + PYTHON_LATEST: 3.13 jobs: diff --git a/.github/workflows/reusable-linters.yml b/.github/workflows/reusable-linters.yml index 68b06d497..e127ea23e 100644 --- a/.github/workflows/reusable-linters.yml +++ b/.github/workflows/reusable-linters.yml @@ -21,7 +21,7 @@ env: PY_COLORS: 1 # Recognized by the `py` package, dependency of `pytest` PYTHONIOENCODING: utf-8 PYTHONUTF8: 1 - PYTHON_LATEST: 3.12 + PYTHON_LATEST: 3.13 jobs: From 129c3cd6df578187af1f64bf61992c385273f4f3 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Wed, 22 Jan 2025 20:15:36 +0100 Subject: [PATCH 06/31] Use Cython alpha --- .github/workflows/ci-cd.yml | 8 -------- MANIFEST.in | 1 - packaging/pep517_backend/_backend.py | 4 ++-- pyproject.toml | 5 ----- requirements/cython.txt | 3 ++- 5 files changed, 4 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 4f6113433..07bfe3d79 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -242,14 +242,6 @@ jobs: uses: py-actions/py-dependency-install@v4 with: path: requirements/test.txt - - name: Install Cython nightly on free-threading - if: matrix.pyver == '3.13t' - run: | - python -m pip uninstall -y cython - python -m pip install cython \ - --pre \ - --extra-index-url \ - https://pypi.anaconda.org/scientific-python-nightly-wheels/simple - name: Determine pre-compiled compatible wheel env: # NOTE: When `pip` is forced to colorize output piped into `jq`, diff --git a/MANIFEST.in b/MANIFEST.in index 6bb7eb82f..904cf6889 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -12,7 +12,6 @@ graft docs graft CHANGES graft requirements graft tests -graft scripts global-exclude *.pyc global-exclude *.cache exclude yarl/*.c diff --git a/packaging/pep517_backend/_backend.py b/packaging/pep517_backend/_backend.py index 72fa134fc..29360d751 100644 --- a/packaging/pep517_backend/_backend.py +++ b/packaging/pep517_backend/_backend.py @@ -374,8 +374,8 @@ def get_requires_for_build_wheel( ) c_ext_build_deps = [] if is_pure_python_build else [ - 'Cython ~= 3.0.0; python_version >= "3.12"', - 'Cython; python_version < "3.12"', + 'Cython == 3.1.0a1; python_version >= "3.13"', + 'Cython ~= 3.0.0; python_version <= "3.12"', ] return _setuptools_get_requires_for_build_wheel( diff --git a/pyproject.toml b/pyproject.toml index 097ffda6e..a7c765d57 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -92,8 +92,3 @@ pure-python = "false" [tool.cibuildwheel.windows] before-test = [] # Windows cmd has different syntax and pip chooses wheels - -[[tool.cibuildwheel.overrides]] -select = "cp313t-*" -build-frontend = "build; args: --no-isolation" -before-build = "bash {package}/scripts/cibw_before_build.sh" diff --git a/requirements/cython.txt b/requirements/cython.txt index 3eaca1624..481be0477 100644 --- a/requirements/cython.txt +++ b/requirements/cython.txt @@ -1 +1,2 @@ -cython==3.0.11 +cython==3.1.0a1; python_version >= '3.13' +cython==3.0.11; python_version <= '3.12' From 9b669a802405d29c5a26ba3e6e1ae4f8612bae9a Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Thu, 23 Jan 2025 12:08:11 +0100 Subject: [PATCH 07/31] Separate codspeed from test requirements --- .github/workflows/ci-cd.yml | 2 +- docs/spelling_wordlist.txt | 1 + pytest.ini | 2 +- requirements/codspeed.txt | 2 + requirements/test.txt | 1 - tests/test_quoting_benchmarks.py | 17 +++++- tests/test_url_benchmarks.py | 96 +++++++++++++++++++++++++++++++- 7 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 requirements/codspeed.txt diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 07bfe3d79..b9917133b 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -393,7 +393,7 @@ jobs: - name: Install dependencies uses: py-actions/py-dependency-install@v4 with: - path: requirements/test.txt + path: requirements/codspeed.txt - name: Determine pre-compiled compatible wheel env: # NOTE: When `pip` is forced to colorize output piped into `jq`, diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index b93394988..ffc162fb0 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -2,6 +2,7 @@ Bluesky Bugfixes Changelog Codecov +CPython Cython GPG IPv diff --git a/pytest.ini b/pytest.ini index 00e75faa7..01189506f 100644 --- a/pytest.ini +++ b/pytest.ini @@ -39,7 +39,7 @@ doctest_optionflags = ALLOW_UNICODE ELLIPSIS # Marks tests with an empty parameterset as xfail(run=False) empty_parameter_set_mark = xfail -faulthandler_timeout = 30 +faulthandler_timeout = 60 filterwarnings = error diff --git a/requirements/codspeed.txt b/requirements/codspeed.txt new file mode 100644 index 000000000..52d96f495 --- /dev/null +++ b/requirements/codspeed.txt @@ -0,0 +1,2 @@ +-r test.txt +pytest-codspeed==3.1.2 diff --git a/requirements/test.txt b/requirements/test.txt index b6eeda6ce..fb2f3647f 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -7,4 +7,3 @@ propcache==0.2.1 pytest==8.3.4 pytest-cov>=2.3.1 pytest-xdist -pytest_codspeed==3.1.0 diff --git a/tests/test_quoting_benchmarks.py b/tests/test_quoting_benchmarks.py index fb71b5a5b..86f3281c1 100644 --- a/tests/test_quoting_benchmarks.py +++ b/tests/test_quoting_benchmarks.py @@ -1,6 +1,11 @@ """codspeed benchmark for yarl._quoting module.""" -from pytest_codspeed import BenchmarkFixture +import pytest + +try: + from pytest_codspeed import BenchmarkFixture +except ImportError: + BenchmarkFixture = None from yarl._quoting import _Quoter, _Unquoter @@ -15,6 +20,7 @@ LONG_QUERY_WITH_PCT = LONG_QUERY + "&d=%25%2F%3F%3A%40%26%3B%3D%2B" +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") def test_quote_query_string(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -22,6 +28,7 @@ def _run() -> None: QUERY_QUOTER("a=1&b=2&c=3&d=4&e=5&f=6&g=7&h=8&i=9&j=0") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") def test_quoter_ascii(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -29,6 +36,7 @@ def _run() -> None: QUOTER_SLASH_SAFE("/path/to") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") def test_quote_long_path(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -36,6 +44,7 @@ def _run() -> None: PATH_QUOTER(LONG_PATH) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") def test_quoter_pct(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -43,6 +52,7 @@ def _run() -> None: QUOTER("abc%0a") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") def test_long_query(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -50,6 +60,7 @@ def _run() -> None: QUERY_QUOTER(LONG_QUERY) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") def test_long_query_with_pct(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -57,6 +68,7 @@ def _run() -> None: QUERY_QUOTER(LONG_QUERY_WITH_PCT) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") def test_quoter_quote_utf8(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -64,6 +76,7 @@ def _run() -> None: PATH_QUOTER("/шлях/файл") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") def test_unquoter_short(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -71,6 +84,7 @@ def _run() -> None: UNQUOTER("/path/to") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") def test_unquoter_long_ascii(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -78,6 +92,7 @@ def _run() -> None: UNQUOTER(LONG_QUERY) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") def test_unquoter_long_pct(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: diff --git a/tests/test_url_benchmarks.py b/tests/test_url_benchmarks.py index c8ae10551..8dc0ed225 100644 --- a/tests/test_url_benchmarks.py +++ b/tests/test_url_benchmarks.py @@ -1,6 +1,11 @@ """codspeed benchmarks for yarl.URL.""" -from pytest_codspeed import BenchmarkFixture +import pytest + +try: + from pytest_codspeed import BenchmarkFixture +except ImportError: + BenchmarkFixture = None from yarl import URL @@ -29,6 +34,7 @@ class _SubClassedStr(str): """A subclass of str that does nothing.""" +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_build_with_host_and_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -36,6 +42,7 @@ def _run() -> None: URL.build(host="www.domain.tld", path="/req", port=1234) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_build_with_simple_query(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -43,6 +50,7 @@ def _run() -> None: URL.build(host="www.domain.tld", query=SIMPLE_QUERY) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_build_no_netloc(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -50,6 +58,7 @@ def _run() -> None: URL.build(path="/req/req/req") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_build_no_netloc_relative(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -57,6 +66,7 @@ def _run() -> None: URL.build(path="req/req/req") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_build_encoded_with_host_and_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -64,6 +74,7 @@ def _run() -> None: URL.build(host="www.domain.tld", path="/req", port=1234, encoded=True) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_build_with_host(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -71,6 +82,7 @@ def _run() -> None: URL.build(host="domain") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_build_access_username_password(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -80,6 +92,7 @@ def _run() -> None: url.raw_password +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_build_access_raw_host(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -88,6 +101,7 @@ def _run() -> None: url.raw_host +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_build_access_fragment(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -96,6 +110,7 @@ def _run() -> None: url.fragment +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_build_access_raw_path(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -104,6 +119,7 @@ def _run() -> None: url.raw_path +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_build_with_different_hosts(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -111,6 +127,7 @@ def _run() -> None: URL.build(host=host) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_build_with_host_path_and_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -118,6 +135,7 @@ def _run() -> None: URL.build(host="www.domain.tld", port=1234) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_no_netloc(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -125,6 +143,7 @@ def _run() -> None: URL("/req/req/req") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_no_netloc_relative(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -132,6 +151,7 @@ def _run() -> None: URL("req/req/req") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_with_host_path_and_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -139,6 +159,7 @@ def _run() -> None: URL("http://www.domain.tld:1234/req") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_encoded_with_host_path_and_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -146,6 +167,7 @@ def _run() -> None: URL("http://www.domain.tld:1234/req", encoded=True) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_with_host_and_path(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -153,6 +175,7 @@ def _run() -> None: URL("http://www.domain.tld") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_with_many_hosts(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -160,6 +183,7 @@ def _run() -> None: URL(url) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_with_many_ipv4_hosts(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -167,6 +191,7 @@ def _run() -> None: URL(url) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_with_many_ipv6_hosts(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -174,6 +199,7 @@ def _run() -> None: URL(url) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_access_raw_host(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -182,6 +208,7 @@ def _run() -> None: url.raw_host +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_raw_host_empty_cache(benchmark: BenchmarkFixture) -> None: url = URL("http://www.domain.tld") @@ -192,6 +219,7 @@ def _run() -> None: url.raw_host +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_access_fragment(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -200,6 +228,7 @@ def _run() -> None: url.fragment +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_access_raw_path(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -208,6 +237,7 @@ def _run() -> None: url.raw_path +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_access_username_password(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -217,6 +247,7 @@ def _run() -> None: url.raw_password +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_empty_username(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -224,6 +255,7 @@ def _run() -> None: URL("http://:password@www.domain.tld") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_empty_password(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -231,6 +263,7 @@ def _run() -> None: URL("http://user:@www.domain.tld") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_with_ipv4_address_path_and_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -238,6 +271,7 @@ def _run() -> None: URL("http://127.0.0.1:1234/req") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_with_ipv4_address_and_path(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -245,6 +279,7 @@ def _run() -> None: URL("http://127.0.0.1/req") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_with_ipv6_address_path_and_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -252,6 +287,7 @@ def _run() -> None: URL("http://[::1]:1234/req") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_make_with_ipv6_address_and_path(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -259,6 +295,7 @@ def _run() -> None: URL("http://[::1]/req") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_extend_query_subclassed_str(benchmark: BenchmarkFixture) -> None: """Test extending a query with a subclassed str.""" subclassed_query = {str(i): _SubClassedStr(i) for i in range(10)} @@ -269,6 +306,7 @@ def _run() -> None: BASE_URL.with_query(subclassed_query) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_with_query_mapping(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -276,6 +314,7 @@ def _run() -> None: BASE_URL.with_query(SIMPLE_QUERY) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_with_query_mapping_int_values(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -283,6 +322,7 @@ def _run() -> None: BASE_URL.with_query(SIMPLE_INT_QUERY) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_with_query_sequence_mapping(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -290,6 +330,7 @@ def _run() -> None: BASE_URL.with_query(QUERY_SEQ) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_with_query_empty(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -297,6 +338,7 @@ def _run() -> None: BASE_URL.with_query({}) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_with_query_none(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -304,6 +346,7 @@ def _run() -> None: BASE_URL.with_query(None) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_update_query_mapping(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -311,6 +354,7 @@ def _run() -> None: BASE_URL.update_query(SIMPLE_QUERY) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_update_query_mapping_with_existing_query(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -318,6 +362,7 @@ def _run() -> None: QUERY_URL.update_query(SIMPLE_QUERY) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_update_query_sequence_mapping(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -325,6 +370,7 @@ def _run() -> None: BASE_URL.update_query(QUERY_SEQ) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_update_query_empty(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -332,6 +378,7 @@ def _run() -> None: BASE_URL.update_query({}) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_update_query_none(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -339,6 +386,7 @@ def _run() -> None: BASE_URL.update_query(None) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_update_query_string(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -346,6 +394,7 @@ def _run() -> None: BASE_URL.update_query(QUERY_STRING) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_extend_query_simple_query_dict(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -353,6 +402,7 @@ def _run() -> None: BASE_URL.extend_query(SIMPLE_QUERY) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_extend_query_existing_query_simple_query_dict( benchmark: BenchmarkFixture, ) -> None: @@ -362,6 +412,7 @@ def _run() -> None: QUERY_URL.extend_query(SIMPLE_QUERY) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_extend_query_existing_query_string(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -369,6 +420,7 @@ def _run() -> None: QUERY_URL.extend_query(QUERY_STRING) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_to_string(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -376,6 +428,7 @@ def _run() -> None: str(BASE_URL) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_with_path_to_string(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -383,6 +436,7 @@ def _run() -> None: str(URL_WITH_PATH) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_with_query_to_string(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -390,6 +444,7 @@ def _run() -> None: str(QUERY_URL) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_with_fragment(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -397,6 +452,7 @@ def _run() -> None: BASE_URL.with_fragment("fragment") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_with_user(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -404,6 +460,7 @@ def _run() -> None: BASE_URL.with_user("user") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_with_password(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -411,6 +468,7 @@ def _run() -> None: BASE_URL.with_password("password") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_with_host(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -418,6 +476,7 @@ def _run() -> None: BASE_URL.with_host("www.domain.tld") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_with_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -425,6 +484,7 @@ def _run() -> None: BASE_URL.with_port(1234) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_with_scheme(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -432,6 +492,7 @@ def _run() -> None: BASE_URL.with_scheme("https") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_with_name(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -439,6 +500,7 @@ def _run() -> None: BASE_URL.with_name("other.tld") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_with_path(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -446,6 +508,7 @@ def _run() -> None: BASE_URL.with_path("/req") +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_origin(benchmark: BenchmarkFixture) -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @@ -455,6 +518,7 @@ def _run() -> None: url.origin() +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_origin_with_user_pass(benchmark: BenchmarkFixture) -> None: urls = [URL(URL_WITH_USER_PASS_STR) for _ in range(100)] @@ -464,6 +528,7 @@ def _run() -> None: url.origin() +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_with_path_origin(benchmark: BenchmarkFixture) -> None: urls = [URL(URL_WITH_PATH_STR) for _ in range(100)] @@ -473,6 +538,7 @@ def _run() -> None: url.origin() +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_with_path_relative(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -480,6 +546,7 @@ def _run() -> None: URL_WITH_PATH.relative() +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_with_path_parent(benchmark: BenchmarkFixture) -> None: cache = URL_WITH_PATH._cache @@ -490,6 +557,7 @@ def _run() -> None: URL_WITH_PATH.parent +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_join(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -497,6 +565,7 @@ def _run() -> None: BASE_URL.join(REL_URL) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_joinpath_encoded(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -504,6 +573,7 @@ def _run() -> None: BASE_URL.joinpath("req", encoded=True) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_joinpath_encoded_long(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -513,6 +583,7 @@ def _run() -> None: ) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_joinpath(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -520,6 +591,7 @@ def _run() -> None: BASE_URL.joinpath("req", encoded=False) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_joinpath_with_truediv(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -527,6 +599,7 @@ def _run() -> None: BASE_URL / "req/req/req" +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_equality(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -536,6 +609,7 @@ def _run() -> None: URL_WITH_PATH == URL_WITH_PATH +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_hash(benchmark: BenchmarkFixture) -> None: cache = BASE_URL._cache @@ -546,6 +620,7 @@ def _run() -> None: hash(BASE_URL) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_is_default_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -554,6 +629,7 @@ def _run() -> None: URL_WITH_NOT_DEFAULT_PORT.is_default_port() +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_human_repr(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -566,6 +642,7 @@ def _run() -> None: REL_URL.human_repr() +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_query_string(benchmark: BenchmarkFixture) -> None: urls = [URL(QUERY_URL_STR) for _ in range(100)] @@ -575,6 +652,7 @@ def _run() -> None: url.query_string +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_empty_query_string(benchmark: BenchmarkFixture) -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @@ -584,6 +662,7 @@ def _run() -> None: url.query_string +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_empty_query_string_uncached(benchmark: BenchmarkFixture) -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @@ -593,6 +672,7 @@ def _run() -> None: URL.query_string.wrapped(url) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_query(benchmark: BenchmarkFixture) -> None: urls = [URL(QUERY_URL_STR) for _ in range(100)] @@ -602,6 +682,7 @@ def _run() -> None: url.query +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_empty_query(benchmark: BenchmarkFixture) -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @@ -611,6 +692,7 @@ def _run() -> None: url.query +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_url_host_port_subcomponent(benchmark: BenchmarkFixture) -> None: cache_non_default = URL_WITH_NOT_DEFAULT_PORT._cache cache = BASE_URL._cache @@ -624,6 +706,7 @@ def _run() -> None: BASE_URL.host_port_subcomponent +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_empty_path(benchmark: BenchmarkFixture) -> None: """Test accessing empty path.""" @@ -633,6 +716,7 @@ def _run() -> None: BASE_URL.path +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_empty_path_uncached(benchmark: BenchmarkFixture) -> None: """Test accessing empty path without cache.""" @@ -642,6 +726,7 @@ def _run() -> None: URL.path.wrapped(BASE_URL) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_empty_path_safe(benchmark: BenchmarkFixture) -> None: """Test accessing empty path safe.""" @@ -651,6 +736,7 @@ def _run() -> None: BASE_URL.path_safe +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_empty_path_safe_uncached(benchmark: BenchmarkFixture) -> None: """Test accessing empty path safe without cache.""" @@ -660,6 +746,7 @@ def _run() -> None: URL.path_safe.wrapped(BASE_URL) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_path_safe(benchmark: BenchmarkFixture) -> None: """Test accessing path safe.""" @@ -669,6 +756,7 @@ def _run() -> None: URL_WITH_PATH.path_safe +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_path_safe_uncached(benchmark: BenchmarkFixture) -> None: """Test accessing path safe without cache.""" @@ -678,6 +766,7 @@ def _run() -> None: URL.path_safe.wrapped(URL_WITH_PATH) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_empty_raw_path_qs(benchmark: BenchmarkFixture) -> None: """Test accessing empty raw path with query.""" @@ -687,6 +776,7 @@ def _run() -> None: BASE_URL.raw_path_qs +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_empty_raw_path_qs_uncached(benchmark: BenchmarkFixture) -> None: """Test accessing empty raw path with query without cache.""" @@ -696,6 +786,7 @@ def _run() -> None: URL.raw_path_qs.wrapped(BASE_URL) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_raw_path_qs(benchmark: BenchmarkFixture) -> None: """Test accessing raw path qs without query.""" @@ -705,6 +796,7 @@ def _run() -> None: URL_WITH_PATH.raw_path_qs +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_raw_path_qs_uncached(benchmark: BenchmarkFixture) -> None: """Test accessing raw path qs without query and without cache.""" @@ -714,6 +806,7 @@ def _run() -> None: URL.raw_path_qs.wrapped(URL_WITH_PATH) +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_raw_path_qs_with_query(benchmark: BenchmarkFixture) -> None: """Test accessing raw path qs with query.""" @@ -723,6 +816,7 @@ def _run() -> None: IPV6_QUERY_URL.raw_path_qs +@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") def test_raw_path_qs_with_query_uncached(benchmark: BenchmarkFixture) -> None: """Test accessing raw path qs with query and without cache.""" From 876ec6edfabc74b664bd2467fe0f7fc226a5a7dc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 23 Jan 2025 11:46:33 +0000 Subject: [PATCH 08/31] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/spelling_wordlist.txt | 2 +- tests/test_quoting_benchmarks.py | 40 ++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index ffc162fb0..95c9c5632 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -1,8 +1,8 @@ Bluesky Bugfixes +CPython Changelog Codecov -CPython Cython GPG IPv diff --git a/tests/test_quoting_benchmarks.py b/tests/test_quoting_benchmarks.py index 86f3281c1..f888dc8ce 100644 --- a/tests/test_quoting_benchmarks.py +++ b/tests/test_quoting_benchmarks.py @@ -20,7 +20,9 @@ LONG_QUERY_WITH_PCT = LONG_QUERY + "&d=%25%2F%3F%3A%40%26%3B%3D%2B" -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") +@pytest.mark.skipif( + BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" +) def test_quote_query_string(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -28,7 +30,9 @@ def _run() -> None: QUERY_QUOTER("a=1&b=2&c=3&d=4&e=5&f=6&g=7&h=8&i=9&j=0") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") +@pytest.mark.skipif( + BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" +) def test_quoter_ascii(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -36,7 +40,9 @@ def _run() -> None: QUOTER_SLASH_SAFE("/path/to") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") +@pytest.mark.skipif( + BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" +) def test_quote_long_path(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -44,7 +50,9 @@ def _run() -> None: PATH_QUOTER(LONG_PATH) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") +@pytest.mark.skipif( + BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" +) def test_quoter_pct(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -52,7 +60,9 @@ def _run() -> None: QUOTER("abc%0a") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") +@pytest.mark.skipif( + BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" +) def test_long_query(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -60,7 +70,9 @@ def _run() -> None: QUERY_QUOTER(LONG_QUERY) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") +@pytest.mark.skipif( + BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" +) def test_long_query_with_pct(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -68,7 +80,9 @@ def _run() -> None: QUERY_QUOTER(LONG_QUERY_WITH_PCT) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") +@pytest.mark.skipif( + BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" +) def test_quoter_quote_utf8(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -76,7 +90,9 @@ def _run() -> None: PATH_QUOTER("/шлях/файл") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") +@pytest.mark.skipif( + BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" +) def test_unquoter_short(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -84,7 +100,9 @@ def _run() -> None: UNQUOTER("/path/to") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") +@pytest.mark.skipif( + BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" +) def test_unquoter_long_ascii(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -92,7 +110,9 @@ def _run() -> None: UNQUOTER(LONG_QUERY) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed") +@pytest.mark.skipif( + BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" +) def test_unquoter_long_pct(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: From 42e13da969a4e750c83c4518481b47f30de7fba9 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Thu, 23 Jan 2025 13:05:14 +0100 Subject: [PATCH 09/31] Add .hypothesis to norecursedirs --- pytest.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/pytest.ini b/pytest.ini index 01189506f..13670e14b 100644 --- a/pytest.ini +++ b/pytest.ini @@ -80,6 +80,7 @@ norecursedirs = .github .tox *.egg + .hypothesis testpaths = tests/ From d1e22ca897ebe38bfd0a756d861169e297cee8cc Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Thu, 23 Jan 2025 13:09:55 +0100 Subject: [PATCH 10/31] Only build with Cython alpha on the free-threaded build --- packaging/pep517_backend/_backend.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packaging/pep517_backend/_backend.py b/packaging/pep517_backend/_backend.py index 231f35073..17e693348 100644 --- a/packaging/pep517_backend/_backend.py +++ b/packaging/pep517_backend/_backend.py @@ -4,6 +4,7 @@ from __future__ import annotations import os +import sysconfig import typing as t from contextlib import contextmanager, nullcontext, suppress from functools import partial @@ -371,10 +372,12 @@ def get_requires_for_build_wheel( stacklevel=999, ) - c_ext_build_deps = [] if is_pure_python_build else [ - 'Cython == 3.1.0a1; python_version >= "3.13"', - 'Cython ~= 3.0.0; python_version <= "3.12"', - ] + if is_pure_python_build: + c_ext_build_deps = [] + elif sysconfig.get_config_var("Py_GIL_DISABLED"): + c_ext_build_deps = ['Cython == 3.1.0a1'] + else: + c_ext_build_deps = ['Cython ~= 3.0.0'] return _setuptools_get_requires_for_build_wheel( config_settings=config_settings, From 505d3efe5f0030164708e7f2d85a4619868d6455 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Mon, 17 Feb 2025 13:26:32 +0100 Subject: [PATCH 11/31] Remove PIP_CONSTRAINT from cibuildwheel; fix linter --- packaging/pep517_backend/_backend.py | 6 +- pyproject.toml | 6 + requirements/cython.txt | 3 +- scripts/cibw_before_build.sh | 7 -- tests/test_quoting_benchmarks.py | 23 ++-- tests/test_url_benchmarks.py | 181 ++++++++++++++------------- 6 files changed, 113 insertions(+), 113 deletions(-) delete mode 100644 scripts/cibw_before_build.sh diff --git a/packaging/pep517_backend/_backend.py b/packaging/pep517_backend/_backend.py index 17e693348..9bbd31f48 100644 --- a/packaging/pep517_backend/_backend.py +++ b/packaging/pep517_backend/_backend.py @@ -374,10 +374,10 @@ def get_requires_for_build_wheel( if is_pure_python_build: c_ext_build_deps = [] - elif sysconfig.get_config_var("Py_GIL_DISABLED"): - c_ext_build_deps = ['Cython == 3.1.0a1'] + elif sysconfig.get_config_var('Py_GIL_DISABLED'): + c_ext_build_deps = ['Cython ~= 3.1.0a1'] else: - c_ext_build_deps = ['Cython ~= 3.0.0'] + c_ext_build_deps = ['Cython ~= 3.0.11'] return _setuptools_get_requires_for_build_wheel( config_settings=config_settings, diff --git a/pyproject.toml b/pyproject.toml index a7c765d57..6b640c435 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,6 +79,12 @@ test-command = 'pytest -v -m "not hypothesis" --no-cov {project}/tests' # don't build PyPy wheels, install from source instead skip = "pp*" +# TODO: Remove this when there's a Cython 3.1 final release +# Remove PIP_CONSTRAINT from the environment +[[tool.cibuildwheel.overrides]] +select = "cp313t-*" +environment = {COLOR="yes", FORCE_COLOR="1", MYPY_FORCE_COLOR="1", PRE_COMMIT_COLOR="always", PY_COLORS="1"} + [tool.cibuildwheel.environment] COLOR = "yes" FORCE_COLOR = "1" diff --git a/requirements/cython.txt b/requirements/cython.txt index 481be0477..8320af396 100644 --- a/requirements/cython.txt +++ b/requirements/cython.txt @@ -1,2 +1 @@ -cython==3.1.0a1; python_version >= '3.13' -cython==3.0.11; python_version <= '3.12' +cython~=3.0.11 diff --git a/scripts/cibw_before_build.sh b/scripts/cibw_before_build.sh deleted file mode 100644 index 718d89d7d..000000000 --- a/scripts/cibw_before_build.sh +++ /dev/null @@ -1,7 +0,0 @@ -# TODO: Delete when there's a PyPI Cython release (3.1.0) that supports free-threaded Python 3.13. -FREE_THREADED_BUILD="$(python -c"import sysconfig; print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')))")" -if [[ $FREE_THREADED_BUILD == "True" ]]; then - python -m pip install -U pip - python -m pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple cython - python -m pip install setuptools expandvars -fi diff --git a/tests/test_quoting_benchmarks.py b/tests/test_quoting_benchmarks.py index f888dc8ce..6499acf2a 100644 --- a/tests/test_quoting_benchmarks.py +++ b/tests/test_quoting_benchmarks.py @@ -4,8 +4,9 @@ try: from pytest_codspeed import BenchmarkFixture + CODSPEED_MISSING = False except ImportError: - BenchmarkFixture = None + CODSPEED_MISSING = True from yarl._quoting import _Quoter, _Unquoter @@ -21,7 +22,7 @@ @pytest.mark.skipif( - BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" + CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" ) def test_quote_query_string(benchmark: BenchmarkFixture) -> None: @benchmark @@ -31,7 +32,7 @@ def _run() -> None: @pytest.mark.skipif( - BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" + CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" ) def test_quoter_ascii(benchmark: BenchmarkFixture) -> None: @benchmark @@ -41,7 +42,7 @@ def _run() -> None: @pytest.mark.skipif( - BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" + CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" ) def test_quote_long_path(benchmark: BenchmarkFixture) -> None: @benchmark @@ -51,7 +52,7 @@ def _run() -> None: @pytest.mark.skipif( - BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" + CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" ) def test_quoter_pct(benchmark: BenchmarkFixture) -> None: @benchmark @@ -61,7 +62,7 @@ def _run() -> None: @pytest.mark.skipif( - BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" + CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" ) def test_long_query(benchmark: BenchmarkFixture) -> None: @benchmark @@ -71,7 +72,7 @@ def _run() -> None: @pytest.mark.skipif( - BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" + CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" ) def test_long_query_with_pct(benchmark: BenchmarkFixture) -> None: @benchmark @@ -81,7 +82,7 @@ def _run() -> None: @pytest.mark.skipif( - BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" + CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" ) def test_quoter_quote_utf8(benchmark: BenchmarkFixture) -> None: @benchmark @@ -91,7 +92,7 @@ def _run() -> None: @pytest.mark.skipif( - BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" + CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" ) def test_unquoter_short(benchmark: BenchmarkFixture) -> None: @benchmark @@ -101,7 +102,7 @@ def _run() -> None: @pytest.mark.skipif( - BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" + CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" ) def test_unquoter_long_ascii(benchmark: BenchmarkFixture) -> None: @benchmark @@ -111,7 +112,7 @@ def _run() -> None: @pytest.mark.skipif( - BenchmarkFixture is None, reason="pytest-codspeed needs to be installed" + CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" ) def test_unquoter_long_pct(benchmark: BenchmarkFixture) -> None: @benchmark diff --git a/tests/test_url_benchmarks.py b/tests/test_url_benchmarks.py index 8dc0ed225..a5a185c15 100644 --- a/tests/test_url_benchmarks.py +++ b/tests/test_url_benchmarks.py @@ -4,8 +4,9 @@ try: from pytest_codspeed import BenchmarkFixture + CODSPEED_MISSING = False except ImportError: - BenchmarkFixture = None + CODSPEED_MISSING = True from yarl import URL @@ -34,7 +35,7 @@ class _SubClassedStr(str): """A subclass of str that does nothing.""" -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_build_with_host_and_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -42,7 +43,7 @@ def _run() -> None: URL.build(host="www.domain.tld", path="/req", port=1234) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_build_with_simple_query(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -50,7 +51,7 @@ def _run() -> None: URL.build(host="www.domain.tld", query=SIMPLE_QUERY) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_build_no_netloc(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -58,7 +59,7 @@ def _run() -> None: URL.build(path="/req/req/req") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_build_no_netloc_relative(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -66,7 +67,7 @@ def _run() -> None: URL.build(path="req/req/req") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_build_encoded_with_host_and_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -74,7 +75,7 @@ def _run() -> None: URL.build(host="www.domain.tld", path="/req", port=1234, encoded=True) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_build_with_host(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -82,7 +83,7 @@ def _run() -> None: URL.build(host="domain") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_build_access_username_password(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -92,7 +93,7 @@ def _run() -> None: url.raw_password -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_build_access_raw_host(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -101,7 +102,7 @@ def _run() -> None: url.raw_host -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_build_access_fragment(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -110,7 +111,7 @@ def _run() -> None: url.fragment -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_build_access_raw_path(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -119,7 +120,7 @@ def _run() -> None: url.raw_path -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_build_with_different_hosts(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -127,7 +128,7 @@ def _run() -> None: URL.build(host=host) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_build_with_host_path_and_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -135,7 +136,7 @@ def _run() -> None: URL.build(host="www.domain.tld", port=1234) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_no_netloc(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -143,7 +144,7 @@ def _run() -> None: URL("/req/req/req") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_no_netloc_relative(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -151,7 +152,7 @@ def _run() -> None: URL("req/req/req") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_with_host_path_and_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -159,7 +160,7 @@ def _run() -> None: URL("http://www.domain.tld:1234/req") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_encoded_with_host_path_and_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -167,7 +168,7 @@ def _run() -> None: URL("http://www.domain.tld:1234/req", encoded=True) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_with_host_and_path(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -175,7 +176,7 @@ def _run() -> None: URL("http://www.domain.tld") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_with_many_hosts(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -183,7 +184,7 @@ def _run() -> None: URL(url) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_with_many_ipv4_hosts(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -191,7 +192,7 @@ def _run() -> None: URL(url) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_with_many_ipv6_hosts(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -199,7 +200,7 @@ def _run() -> None: URL(url) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_access_raw_host(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -208,7 +209,7 @@ def _run() -> None: url.raw_host -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_raw_host_empty_cache(benchmark: BenchmarkFixture) -> None: url = URL("http://www.domain.tld") @@ -219,7 +220,7 @@ def _run() -> None: url.raw_host -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_access_fragment(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -228,7 +229,7 @@ def _run() -> None: url.fragment -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_access_raw_path(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -237,7 +238,7 @@ def _run() -> None: url.raw_path -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_access_username_password(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -247,7 +248,7 @@ def _run() -> None: url.raw_password -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_empty_username(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -255,7 +256,7 @@ def _run() -> None: URL("http://:password@www.domain.tld") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_empty_password(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -263,7 +264,7 @@ def _run() -> None: URL("http://user:@www.domain.tld") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_with_ipv4_address_path_and_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -271,7 +272,7 @@ def _run() -> None: URL("http://127.0.0.1:1234/req") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_with_ipv4_address_and_path(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -279,7 +280,7 @@ def _run() -> None: URL("http://127.0.0.1/req") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_with_ipv6_address_path_and_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -287,7 +288,7 @@ def _run() -> None: URL("http://[::1]:1234/req") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_with_ipv6_address_and_path(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -295,7 +296,7 @@ def _run() -> None: URL("http://[::1]/req") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_extend_query_subclassed_str(benchmark: BenchmarkFixture) -> None: """Test extending a query with a subclassed str.""" subclassed_query = {str(i): _SubClassedStr(i) for i in range(10)} @@ -306,7 +307,7 @@ def _run() -> None: BASE_URL.with_query(subclassed_query) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_with_query_mapping(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -314,7 +315,7 @@ def _run() -> None: BASE_URL.with_query(SIMPLE_QUERY) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_with_query_mapping_int_values(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -322,7 +323,7 @@ def _run() -> None: BASE_URL.with_query(SIMPLE_INT_QUERY) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_with_query_sequence_mapping(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -330,7 +331,7 @@ def _run() -> None: BASE_URL.with_query(QUERY_SEQ) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_with_query_empty(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -338,7 +339,7 @@ def _run() -> None: BASE_URL.with_query({}) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_with_query_none(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -346,7 +347,7 @@ def _run() -> None: BASE_URL.with_query(None) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_update_query_mapping(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -354,7 +355,7 @@ def _run() -> None: BASE_URL.update_query(SIMPLE_QUERY) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_update_query_mapping_with_existing_query(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -362,7 +363,7 @@ def _run() -> None: QUERY_URL.update_query(SIMPLE_QUERY) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_update_query_sequence_mapping(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -370,7 +371,7 @@ def _run() -> None: BASE_URL.update_query(QUERY_SEQ) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_update_query_empty(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -378,7 +379,7 @@ def _run() -> None: BASE_URL.update_query({}) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_update_query_none(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -386,7 +387,7 @@ def _run() -> None: BASE_URL.update_query(None) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_update_query_string(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -394,7 +395,7 @@ def _run() -> None: BASE_URL.update_query(QUERY_STRING) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_extend_query_simple_query_dict(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -402,7 +403,7 @@ def _run() -> None: BASE_URL.extend_query(SIMPLE_QUERY) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_extend_query_existing_query_simple_query_dict( benchmark: BenchmarkFixture, ) -> None: @@ -412,7 +413,7 @@ def _run() -> None: QUERY_URL.extend_query(SIMPLE_QUERY) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_extend_query_existing_query_string(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -420,7 +421,7 @@ def _run() -> None: QUERY_URL.extend_query(QUERY_STRING) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_to_string(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -428,7 +429,7 @@ def _run() -> None: str(BASE_URL) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_with_path_to_string(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -436,7 +437,7 @@ def _run() -> None: str(URL_WITH_PATH) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_with_query_to_string(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -444,7 +445,7 @@ def _run() -> None: str(QUERY_URL) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_with_fragment(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -452,7 +453,7 @@ def _run() -> None: BASE_URL.with_fragment("fragment") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_with_user(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -460,7 +461,7 @@ def _run() -> None: BASE_URL.with_user("user") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_with_password(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -468,7 +469,7 @@ def _run() -> None: BASE_URL.with_password("password") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_with_host(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -476,7 +477,7 @@ def _run() -> None: BASE_URL.with_host("www.domain.tld") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_with_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -484,7 +485,7 @@ def _run() -> None: BASE_URL.with_port(1234) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_with_scheme(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -492,7 +493,7 @@ def _run() -> None: BASE_URL.with_scheme("https") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_with_name(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -500,7 +501,7 @@ def _run() -> None: BASE_URL.with_name("other.tld") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_with_path(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -508,7 +509,7 @@ def _run() -> None: BASE_URL.with_path("/req") -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_origin(benchmark: BenchmarkFixture) -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @@ -518,7 +519,7 @@ def _run() -> None: url.origin() -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_origin_with_user_pass(benchmark: BenchmarkFixture) -> None: urls = [URL(URL_WITH_USER_PASS_STR) for _ in range(100)] @@ -528,7 +529,7 @@ def _run() -> None: url.origin() -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_with_path_origin(benchmark: BenchmarkFixture) -> None: urls = [URL(URL_WITH_PATH_STR) for _ in range(100)] @@ -538,7 +539,7 @@ def _run() -> None: url.origin() -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_with_path_relative(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -546,7 +547,7 @@ def _run() -> None: URL_WITH_PATH.relative() -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_with_path_parent(benchmark: BenchmarkFixture) -> None: cache = URL_WITH_PATH._cache @@ -557,7 +558,7 @@ def _run() -> None: URL_WITH_PATH.parent -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_join(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -565,7 +566,7 @@ def _run() -> None: BASE_URL.join(REL_URL) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_joinpath_encoded(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -573,7 +574,7 @@ def _run() -> None: BASE_URL.joinpath("req", encoded=True) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_joinpath_encoded_long(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -583,7 +584,7 @@ def _run() -> None: ) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_joinpath(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -591,7 +592,7 @@ def _run() -> None: BASE_URL.joinpath("req", encoded=False) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_joinpath_with_truediv(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -599,7 +600,7 @@ def _run() -> None: BASE_URL / "req/req/req" -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_equality(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -609,7 +610,7 @@ def _run() -> None: URL_WITH_PATH == URL_WITH_PATH -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_hash(benchmark: BenchmarkFixture) -> None: cache = BASE_URL._cache @@ -620,7 +621,7 @@ def _run() -> None: hash(BASE_URL) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_is_default_port(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -629,7 +630,7 @@ def _run() -> None: URL_WITH_NOT_DEFAULT_PORT.is_default_port() -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_human_repr(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -642,7 +643,7 @@ def _run() -> None: REL_URL.human_repr() -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_query_string(benchmark: BenchmarkFixture) -> None: urls = [URL(QUERY_URL_STR) for _ in range(100)] @@ -652,7 +653,7 @@ def _run() -> None: url.query_string -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_empty_query_string(benchmark: BenchmarkFixture) -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @@ -662,7 +663,7 @@ def _run() -> None: url.query_string -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_empty_query_string_uncached(benchmark: BenchmarkFixture) -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @@ -672,7 +673,7 @@ def _run() -> None: URL.query_string.wrapped(url) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_query(benchmark: BenchmarkFixture) -> None: urls = [URL(QUERY_URL_STR) for _ in range(100)] @@ -682,7 +683,7 @@ def _run() -> None: url.query -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_empty_query(benchmark: BenchmarkFixture) -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @@ -692,7 +693,7 @@ def _run() -> None: url.query -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_host_port_subcomponent(benchmark: BenchmarkFixture) -> None: cache_non_default = URL_WITH_NOT_DEFAULT_PORT._cache cache = BASE_URL._cache @@ -706,7 +707,7 @@ def _run() -> None: BASE_URL.host_port_subcomponent -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_empty_path(benchmark: BenchmarkFixture) -> None: """Test accessing empty path.""" @@ -716,7 +717,7 @@ def _run() -> None: BASE_URL.path -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_empty_path_uncached(benchmark: BenchmarkFixture) -> None: """Test accessing empty path without cache.""" @@ -726,7 +727,7 @@ def _run() -> None: URL.path.wrapped(BASE_URL) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_empty_path_safe(benchmark: BenchmarkFixture) -> None: """Test accessing empty path safe.""" @@ -736,7 +737,7 @@ def _run() -> None: BASE_URL.path_safe -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_empty_path_safe_uncached(benchmark: BenchmarkFixture) -> None: """Test accessing empty path safe without cache.""" @@ -746,7 +747,7 @@ def _run() -> None: URL.path_safe.wrapped(BASE_URL) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_path_safe(benchmark: BenchmarkFixture) -> None: """Test accessing path safe.""" @@ -756,7 +757,7 @@ def _run() -> None: URL_WITH_PATH.path_safe -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_path_safe_uncached(benchmark: BenchmarkFixture) -> None: """Test accessing path safe without cache.""" @@ -766,7 +767,7 @@ def _run() -> None: URL.path_safe.wrapped(URL_WITH_PATH) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_empty_raw_path_qs(benchmark: BenchmarkFixture) -> None: """Test accessing empty raw path with query.""" @@ -776,7 +777,7 @@ def _run() -> None: BASE_URL.raw_path_qs -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_empty_raw_path_qs_uncached(benchmark: BenchmarkFixture) -> None: """Test accessing empty raw path with query without cache.""" @@ -786,7 +787,7 @@ def _run() -> None: URL.raw_path_qs.wrapped(BASE_URL) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_raw_path_qs(benchmark: BenchmarkFixture) -> None: """Test accessing raw path qs without query.""" @@ -796,7 +797,7 @@ def _run() -> None: URL_WITH_PATH.raw_path_qs -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_raw_path_qs_uncached(benchmark: BenchmarkFixture) -> None: """Test accessing raw path qs without query and without cache.""" @@ -806,7 +807,7 @@ def _run() -> None: URL.raw_path_qs.wrapped(URL_WITH_PATH) -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_raw_path_qs_with_query(benchmark: BenchmarkFixture) -> None: """Test accessing raw path qs with query.""" @@ -816,7 +817,7 @@ def _run() -> None: IPV6_QUERY_URL.raw_path_qs -@pytest.mark.skipif(BenchmarkFixture is None, reason="pytest-codspeed is not installed") +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_raw_path_qs_with_query_uncached(benchmark: BenchmarkFixture) -> None: """Test accessing raw path qs with query and without cache.""" From 44ee894acbb06b440a072a5f9a73e7e4f40eed60 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 13:05:06 +0000 Subject: [PATCH 12/31] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_quoting_benchmarks.py | 41 +++++++++----------------------- tests/test_url_benchmarks.py | 1 + 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/tests/test_quoting_benchmarks.py b/tests/test_quoting_benchmarks.py index 6499acf2a..25655c03c 100644 --- a/tests/test_quoting_benchmarks.py +++ b/tests/test_quoting_benchmarks.py @@ -4,6 +4,7 @@ try: from pytest_codspeed import BenchmarkFixture + CODSPEED_MISSING = False except ImportError: CODSPEED_MISSING = True @@ -21,9 +22,7 @@ LONG_QUERY_WITH_PCT = LONG_QUERY + "&d=%25%2F%3F%3A%40%26%3B%3D%2B" -@pytest.mark.skipif( - CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" -) +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") def test_quote_query_string(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -31,9 +30,7 @@ def _run() -> None: QUERY_QUOTER("a=1&b=2&c=3&d=4&e=5&f=6&g=7&h=8&i=9&j=0") -@pytest.mark.skipif( - CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" -) +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") def test_quoter_ascii(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -41,9 +38,7 @@ def _run() -> None: QUOTER_SLASH_SAFE("/path/to") -@pytest.mark.skipif( - CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" -) +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") def test_quote_long_path(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -51,9 +46,7 @@ def _run() -> None: PATH_QUOTER(LONG_PATH) -@pytest.mark.skipif( - CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" -) +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") def test_quoter_pct(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -61,9 +54,7 @@ def _run() -> None: QUOTER("abc%0a") -@pytest.mark.skipif( - CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" -) +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") def test_long_query(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -71,9 +62,7 @@ def _run() -> None: QUERY_QUOTER(LONG_QUERY) -@pytest.mark.skipif( - CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" -) +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") def test_long_query_with_pct(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -81,9 +70,7 @@ def _run() -> None: QUERY_QUOTER(LONG_QUERY_WITH_PCT) -@pytest.mark.skipif( - CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" -) +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") def test_quoter_quote_utf8(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -91,9 +78,7 @@ def _run() -> None: PATH_QUOTER("/шлях/файл") -@pytest.mark.skipif( - CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" -) +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") def test_unquoter_short(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -101,9 +86,7 @@ def _run() -> None: UNQUOTER("/path/to") -@pytest.mark.skipif( - CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" -) +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") def test_unquoter_long_ascii(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: @@ -111,9 +94,7 @@ def _run() -> None: UNQUOTER(LONG_QUERY) -@pytest.mark.skipif( - CODSPEED_MISSING, reason="pytest-codspeed needs to be installed" -) +@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") def test_unquoter_long_pct(benchmark: BenchmarkFixture) -> None: @benchmark def _run() -> None: diff --git a/tests/test_url_benchmarks.py b/tests/test_url_benchmarks.py index a5a185c15..f34901bd3 100644 --- a/tests/test_url_benchmarks.py +++ b/tests/test_url_benchmarks.py @@ -4,6 +4,7 @@ try: from pytest_codspeed import BenchmarkFixture + CODSPEED_MISSING = False except ImportError: CODSPEED_MISSING = True From ce307838fba18d40b95b1799b5d756bee841d266 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Mon, 17 Feb 2025 14:20:16 +0100 Subject: [PATCH 13/31] Delay annotations for codspeed fixture --- tests/test_quoting_benchmarks.py | 20 ++-- tests/test_url_benchmarks.py | 178 +++++++++++++++---------------- 2 files changed, 99 insertions(+), 99 deletions(-) diff --git a/tests/test_quoting_benchmarks.py b/tests/test_quoting_benchmarks.py index 25655c03c..8e482b4d9 100644 --- a/tests/test_quoting_benchmarks.py +++ b/tests/test_quoting_benchmarks.py @@ -23,7 +23,7 @@ @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_quote_query_string(benchmark: BenchmarkFixture) -> None: +def test_quote_query_string(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -31,7 +31,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_quoter_ascii(benchmark: BenchmarkFixture) -> None: +def test_quoter_ascii(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -39,7 +39,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_quote_long_path(benchmark: BenchmarkFixture) -> None: +def test_quote_long_path(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -47,7 +47,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_quoter_pct(benchmark: BenchmarkFixture) -> None: +def test_quoter_pct(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -55,7 +55,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_long_query(benchmark: BenchmarkFixture) -> None: +def test_long_query(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -63,7 +63,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_long_query_with_pct(benchmark: BenchmarkFixture) -> None: +def test_long_query_with_pct(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -71,7 +71,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_quoter_quote_utf8(benchmark: BenchmarkFixture) -> None: +def test_quoter_quote_utf8(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -79,7 +79,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_unquoter_short(benchmark: BenchmarkFixture) -> None: +def test_unquoter_short(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -87,7 +87,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_unquoter_long_ascii(benchmark: BenchmarkFixture) -> None: +def test_unquoter_long_ascii(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -95,7 +95,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_unquoter_long_pct(benchmark: BenchmarkFixture) -> None: +def test_unquoter_long_pct(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): diff --git a/tests/test_url_benchmarks.py b/tests/test_url_benchmarks.py index f34901bd3..f9c04edd3 100644 --- a/tests/test_url_benchmarks.py +++ b/tests/test_url_benchmarks.py @@ -37,7 +37,7 @@ class _SubClassedStr(str): @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_with_host_and_port(benchmark: BenchmarkFixture) -> None: +def test_url_build_with_host_and_port(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -45,7 +45,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_with_simple_query(benchmark: BenchmarkFixture) -> None: +def test_url_build_with_simple_query(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -53,7 +53,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_no_netloc(benchmark: BenchmarkFixture) -> None: +def test_url_build_no_netloc(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -61,7 +61,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_no_netloc_relative(benchmark: BenchmarkFixture) -> None: +def test_url_build_no_netloc_relative(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -69,7 +69,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_encoded_with_host_and_port(benchmark: BenchmarkFixture) -> None: +def test_url_build_encoded_with_host_and_port(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -77,7 +77,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_with_host(benchmark: BenchmarkFixture) -> None: +def test_url_build_with_host(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -85,7 +85,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_access_username_password(benchmark: BenchmarkFixture) -> None: +def test_url_build_access_username_password(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -95,7 +95,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_access_raw_host(benchmark: BenchmarkFixture) -> None: +def test_url_build_access_raw_host(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -104,7 +104,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_access_fragment(benchmark: BenchmarkFixture) -> None: +def test_url_build_access_fragment(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -113,7 +113,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_access_raw_path(benchmark: BenchmarkFixture) -> None: +def test_url_build_access_raw_path(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -122,7 +122,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_with_different_hosts(benchmark: BenchmarkFixture) -> None: +def test_url_build_with_different_hosts(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for host in MANY_HOSTS: @@ -130,7 +130,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_with_host_path_and_port(benchmark: BenchmarkFixture) -> None: +def test_url_build_with_host_path_and_port(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -138,7 +138,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_no_netloc(benchmark: BenchmarkFixture) -> None: +def test_url_make_no_netloc(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -146,7 +146,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_no_netloc_relative(benchmark: BenchmarkFixture) -> None: +def test_url_make_no_netloc_relative(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -154,7 +154,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_host_path_and_port(benchmark: BenchmarkFixture) -> None: +def test_url_make_with_host_path_and_port(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -162,7 +162,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_encoded_with_host_path_and_port(benchmark: BenchmarkFixture) -> None: +def test_url_make_encoded_with_host_path_and_port(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -170,7 +170,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_host_and_path(benchmark: BenchmarkFixture) -> None: +def test_url_make_with_host_and_path(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -178,7 +178,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_many_hosts(benchmark: BenchmarkFixture) -> None: +def test_url_make_with_many_hosts(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for url in MANY_URLS: @@ -186,7 +186,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_many_ipv4_hosts(benchmark: BenchmarkFixture) -> None: +def test_url_make_with_many_ipv4_hosts(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for url in MANY_IPV4_URLS: @@ -194,7 +194,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_many_ipv6_hosts(benchmark: BenchmarkFixture) -> None: +def test_url_make_with_many_ipv6_hosts(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for url in MANY_IPV6_URLS: @@ -202,7 +202,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_access_raw_host(benchmark: BenchmarkFixture) -> None: +def test_url_make_access_raw_host(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -211,7 +211,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_raw_host_empty_cache(benchmark: BenchmarkFixture) -> None: +def test_raw_host_empty_cache(benchmark: "BenchmarkFixture") -> None: url = URL("http://www.domain.tld") @benchmark @@ -222,7 +222,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_access_fragment(benchmark: BenchmarkFixture) -> None: +def test_url_make_access_fragment(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -231,7 +231,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_access_raw_path(benchmark: BenchmarkFixture) -> None: +def test_url_make_access_raw_path(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -240,7 +240,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_access_username_password(benchmark: BenchmarkFixture) -> None: +def test_url_make_access_username_password(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -250,7 +250,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_empty_username(benchmark: BenchmarkFixture) -> None: +def test_url_make_empty_username(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -258,7 +258,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_empty_password(benchmark: BenchmarkFixture) -> None: +def test_url_make_empty_password(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -266,7 +266,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_ipv4_address_path_and_port(benchmark: BenchmarkFixture) -> None: +def test_url_make_with_ipv4_address_path_and_port(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -274,7 +274,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_ipv4_address_and_path(benchmark: BenchmarkFixture) -> None: +def test_url_make_with_ipv4_address_and_path(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -282,7 +282,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_ipv6_address_path_and_port(benchmark: BenchmarkFixture) -> None: +def test_url_make_with_ipv6_address_path_and_port(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -290,7 +290,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_ipv6_address_and_path(benchmark: BenchmarkFixture) -> None: +def test_url_make_with_ipv6_address_and_path(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -298,7 +298,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_extend_query_subclassed_str(benchmark: BenchmarkFixture) -> None: +def test_extend_query_subclassed_str(benchmark: "BenchmarkFixture") -> None: """Test extending a query with a subclassed str.""" subclassed_query = {str(i): _SubClassedStr(i) for i in range(10)} @@ -309,7 +309,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_with_query_mapping(benchmark: BenchmarkFixture) -> None: +def test_with_query_mapping(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): @@ -317,7 +317,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_with_query_mapping_int_values(benchmark: BenchmarkFixture) -> None: +def test_with_query_mapping_int_values(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): @@ -325,7 +325,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_with_query_sequence_mapping(benchmark: BenchmarkFixture) -> None: +def test_with_query_sequence_mapping(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): @@ -333,7 +333,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_with_query_empty(benchmark: BenchmarkFixture) -> None: +def test_with_query_empty(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): @@ -341,7 +341,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_with_query_none(benchmark: BenchmarkFixture) -> None: +def test_with_query_none(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): @@ -349,7 +349,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_update_query_mapping(benchmark: BenchmarkFixture) -> None: +def test_update_query_mapping(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): @@ -357,7 +357,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_update_query_mapping_with_existing_query(benchmark: BenchmarkFixture) -> None: +def test_update_query_mapping_with_existing_query(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): @@ -365,7 +365,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_update_query_sequence_mapping(benchmark: BenchmarkFixture) -> None: +def test_update_query_sequence_mapping(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): @@ -373,7 +373,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_update_query_empty(benchmark: BenchmarkFixture) -> None: +def test_update_query_empty(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): @@ -381,7 +381,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_update_query_none(benchmark: BenchmarkFixture) -> None: +def test_update_query_none(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): @@ -389,7 +389,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_update_query_string(benchmark: BenchmarkFixture) -> None: +def test_update_query_string(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): @@ -397,7 +397,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_extend_query_simple_query_dict(benchmark: BenchmarkFixture) -> None: +def test_url_extend_query_simple_query_dict(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): @@ -406,7 +406,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_extend_query_existing_query_simple_query_dict( - benchmark: BenchmarkFixture, + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -415,7 +415,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_extend_query_existing_query_string(benchmark: BenchmarkFixture) -> None: +def test_url_extend_query_existing_query_string(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): @@ -423,7 +423,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_to_string(benchmark: BenchmarkFixture) -> None: +def test_url_to_string(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -431,7 +431,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_path_to_string(benchmark: BenchmarkFixture) -> None: +def test_url_with_path_to_string(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -439,7 +439,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_query_to_string(benchmark: BenchmarkFixture) -> None: +def test_url_with_query_to_string(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -447,7 +447,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_fragment(benchmark: BenchmarkFixture) -> None: +def test_url_with_fragment(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -455,7 +455,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_user(benchmark: BenchmarkFixture) -> None: +def test_url_with_user(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -463,7 +463,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_password(benchmark: BenchmarkFixture) -> None: +def test_url_with_password(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -471,7 +471,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_host(benchmark: BenchmarkFixture) -> None: +def test_url_with_host(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -479,7 +479,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_port(benchmark: BenchmarkFixture) -> None: +def test_url_with_port(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -487,7 +487,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_scheme(benchmark: BenchmarkFixture) -> None: +def test_url_with_scheme(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -495,7 +495,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_name(benchmark: BenchmarkFixture) -> None: +def test_url_with_name(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -503,7 +503,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_path(benchmark: BenchmarkFixture) -> None: +def test_url_with_path(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -511,7 +511,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_origin(benchmark: BenchmarkFixture) -> None: +def test_url_origin(benchmark: "BenchmarkFixture") -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @benchmark @@ -521,7 +521,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_origin_with_user_pass(benchmark: BenchmarkFixture) -> None: +def test_url_origin_with_user_pass(benchmark: "BenchmarkFixture") -> None: urls = [URL(URL_WITH_USER_PASS_STR) for _ in range(100)] @benchmark @@ -531,7 +531,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_path_origin(benchmark: BenchmarkFixture) -> None: +def test_url_with_path_origin(benchmark: "BenchmarkFixture") -> None: urls = [URL(URL_WITH_PATH_STR) for _ in range(100)] @benchmark @@ -541,7 +541,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_path_relative(benchmark: BenchmarkFixture) -> None: +def test_url_with_path_relative(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -549,7 +549,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_path_parent(benchmark: BenchmarkFixture) -> None: +def test_url_with_path_parent(benchmark: "BenchmarkFixture") -> None: cache = URL_WITH_PATH._cache @benchmark @@ -560,7 +560,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_join(benchmark: BenchmarkFixture) -> None: +def test_url_join(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -568,7 +568,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_joinpath_encoded(benchmark: BenchmarkFixture) -> None: +def test_url_joinpath_encoded(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -576,7 +576,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_joinpath_encoded_long(benchmark: BenchmarkFixture) -> None: +def test_url_joinpath_encoded_long(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -586,7 +586,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_joinpath(benchmark: BenchmarkFixture) -> None: +def test_url_joinpath(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -594,7 +594,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_joinpath_with_truediv(benchmark: BenchmarkFixture) -> None: +def test_url_joinpath_with_truediv(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -602,7 +602,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_equality(benchmark: BenchmarkFixture) -> None: +def test_url_equality(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -612,7 +612,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_hash(benchmark: BenchmarkFixture) -> None: +def test_url_hash(benchmark: "BenchmarkFixture") -> None: cache = BASE_URL._cache @benchmark @@ -623,7 +623,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_is_default_port(benchmark: BenchmarkFixture) -> None: +def test_is_default_port(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -632,7 +632,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_human_repr(benchmark: BenchmarkFixture) -> None: +def test_human_repr(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -645,7 +645,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_query_string(benchmark: BenchmarkFixture) -> None: +def test_query_string(benchmark: "BenchmarkFixture") -> None: urls = [URL(QUERY_URL_STR) for _ in range(100)] @benchmark @@ -655,7 +655,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_query_string(benchmark: BenchmarkFixture) -> None: +def test_empty_query_string(benchmark: "BenchmarkFixture") -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @benchmark @@ -665,7 +665,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_query_string_uncached(benchmark: BenchmarkFixture) -> None: +def test_empty_query_string_uncached(benchmark: "BenchmarkFixture") -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @benchmark @@ -675,7 +675,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_query(benchmark: BenchmarkFixture) -> None: +def test_query(benchmark: "BenchmarkFixture") -> None: urls = [URL(QUERY_URL_STR) for _ in range(100)] @benchmark @@ -685,7 +685,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_query(benchmark: BenchmarkFixture) -> None: +def test_empty_query(benchmark: "BenchmarkFixture") -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @benchmark @@ -695,7 +695,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_host_port_subcomponent(benchmark: BenchmarkFixture) -> None: +def test_url_host_port_subcomponent(benchmark: "BenchmarkFixture") -> None: cache_non_default = URL_WITH_NOT_DEFAULT_PORT._cache cache = BASE_URL._cache @@ -709,7 +709,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_path(benchmark: BenchmarkFixture) -> None: +def test_empty_path(benchmark: "BenchmarkFixture") -> None: """Test accessing empty path.""" @benchmark @@ -719,7 +719,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_path_uncached(benchmark: BenchmarkFixture) -> None: +def test_empty_path_uncached(benchmark: "BenchmarkFixture") -> None: """Test accessing empty path without cache.""" @benchmark @@ -729,7 +729,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_path_safe(benchmark: BenchmarkFixture) -> None: +def test_empty_path_safe(benchmark: "BenchmarkFixture") -> None: """Test accessing empty path safe.""" @benchmark @@ -739,7 +739,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_path_safe_uncached(benchmark: BenchmarkFixture) -> None: +def test_empty_path_safe_uncached(benchmark: "BenchmarkFixture") -> None: """Test accessing empty path safe without cache.""" @benchmark @@ -749,7 +749,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_path_safe(benchmark: BenchmarkFixture) -> None: +def test_path_safe(benchmark: "BenchmarkFixture") -> None: """Test accessing path safe.""" @benchmark @@ -759,7 +759,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_path_safe_uncached(benchmark: BenchmarkFixture) -> None: +def test_path_safe_uncached(benchmark: "BenchmarkFixture") -> None: """Test accessing path safe without cache.""" @benchmark @@ -769,7 +769,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_raw_path_qs(benchmark: BenchmarkFixture) -> None: +def test_empty_raw_path_qs(benchmark: "BenchmarkFixture") -> None: """Test accessing empty raw path with query.""" @benchmark @@ -779,7 +779,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_raw_path_qs_uncached(benchmark: BenchmarkFixture) -> None: +def test_empty_raw_path_qs_uncached(benchmark: "BenchmarkFixture") -> None: """Test accessing empty raw path with query without cache.""" @benchmark @@ -789,7 +789,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_raw_path_qs(benchmark: BenchmarkFixture) -> None: +def test_raw_path_qs(benchmark: "BenchmarkFixture") -> None: """Test accessing raw path qs without query.""" @benchmark @@ -799,7 +799,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_raw_path_qs_uncached(benchmark: BenchmarkFixture) -> None: +def test_raw_path_qs_uncached(benchmark: "BenchmarkFixture") -> None: """Test accessing raw path qs without query and without cache.""" @benchmark @@ -809,7 +809,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_raw_path_qs_with_query(benchmark: BenchmarkFixture) -> None: +def test_raw_path_qs_with_query(benchmark: "BenchmarkFixture") -> None: """Test accessing raw path qs with query.""" @benchmark @@ -819,7 +819,7 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_raw_path_qs_with_query_uncached(benchmark: BenchmarkFixture) -> None: +def test_raw_path_qs_with_query_uncached(benchmark: "BenchmarkFixture") -> None: """Test accessing raw path qs with query and without cache.""" @benchmark From 10269c2dc30eda4305b05105398efc613ed7aa77 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 13:21:05 +0000 Subject: [PATCH 14/31] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_url_benchmarks.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/test_url_benchmarks.py b/tests/test_url_benchmarks.py index f9c04edd3..541b5e81e 100644 --- a/tests/test_url_benchmarks.py +++ b/tests/test_url_benchmarks.py @@ -162,7 +162,9 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_encoded_with_host_path_and_port(benchmark: "BenchmarkFixture") -> None: +def test_url_make_encoded_with_host_path_and_port( + benchmark: "BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): @@ -266,7 +268,9 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_ipv4_address_path_and_port(benchmark: "BenchmarkFixture") -> None: +def test_url_make_with_ipv4_address_path_and_port( + benchmark: "BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): @@ -282,7 +286,9 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_ipv6_address_path_and_port(benchmark: "BenchmarkFixture") -> None: +def test_url_make_with_ipv6_address_path_and_port( + benchmark: "BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): @@ -357,7 +363,9 @@ def _run() -> None: @pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_update_query_mapping_with_existing_query(benchmark: "BenchmarkFixture") -> None: +def test_update_query_mapping_with_existing_query( + benchmark: "BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(25): From 7cb880b6354d5d3c8e8273f38ceb527253f80ec7 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Mon, 17 Feb 2025 15:02:57 +0100 Subject: [PATCH 15/31] Install codspeed when running tests --- .github/workflows/ci-cd.yml | 2 +- requirements/dev.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index b9917133b..a6b67987a 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -241,7 +241,7 @@ jobs: - name: Install dependencies uses: py-actions/py-dependency-install@v4 with: - path: requirements/test.txt + path: requirements/codspeed.txt - name: Determine pre-compiled compatible wheel env: # NOTE: When `pip` is forced to colorize output piped into `jq`, diff --git a/requirements/dev.txt b/requirements/dev.txt index 2a4069d37..f1d0b3003 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,2 +1,2 @@ --r test.txt +-r codspeed.txt -r towncrier.txt From 2aeced1ee6aa415563820fe0ced43f291efe4fc1 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Mon, 17 Feb 2025 15:30:16 +0100 Subject: [PATCH 16/31] Address feedback; use pytest.importorskip --- tests/test_quoting_benchmarks.py | 38 ++-- tests/test_url_benchmarks.py | 349 +++++++++++++++---------------- 2 files changed, 177 insertions(+), 210 deletions(-) diff --git a/tests/test_quoting_benchmarks.py b/tests/test_quoting_benchmarks.py index 8e482b4d9..59a1b5da2 100644 --- a/tests/test_quoting_benchmarks.py +++ b/tests/test_quoting_benchmarks.py @@ -2,14 +2,10 @@ import pytest -try: - from pytest_codspeed import BenchmarkFixture +from yarl._quoting import _Quoter, _Unquoter - CODSPEED_MISSING = False -except ImportError: - CODSPEED_MISSING = True +pytest_codspeed = pytest.importorskip("pytest_codspeed") -from yarl._quoting import _Quoter, _Unquoter QUOTER_SLASH_SAFE = _Quoter(safe="/") QUOTER = _Quoter() @@ -22,80 +18,70 @@ LONG_QUERY_WITH_PCT = LONG_QUERY + "&d=%25%2F%3F%3A%40%26%3B%3D%2B" -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_quote_query_string(benchmark: "BenchmarkFixture") -> None: +def test_quote_query_string(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): QUERY_QUOTER("a=1&b=2&c=3&d=4&e=5&f=6&g=7&h=8&i=9&j=0") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_quoter_ascii(benchmark: "BenchmarkFixture") -> None: +def test_quoter_ascii(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): QUOTER_SLASH_SAFE("/path/to") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_quote_long_path(benchmark: "BenchmarkFixture") -> None: +def test_quote_long_path(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): PATH_QUOTER(LONG_PATH) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_quoter_pct(benchmark: "BenchmarkFixture") -> None: +def test_quoter_pct(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): QUOTER("abc%0a") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_long_query(benchmark: "BenchmarkFixture") -> None: +def test_long_query(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): QUERY_QUOTER(LONG_QUERY) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_long_query_with_pct(benchmark: "BenchmarkFixture") -> None: +def test_long_query_with_pct(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): QUERY_QUOTER(LONG_QUERY_WITH_PCT) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_quoter_quote_utf8(benchmark: "BenchmarkFixture") -> None: +def test_quoter_quote_utf8(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): PATH_QUOTER("/шлях/файл") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_unquoter_short(benchmark: "BenchmarkFixture") -> None: +def test_unquoter_short(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): UNQUOTER("/path/to") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_unquoter_long_ascii(benchmark: "BenchmarkFixture") -> None: +def test_unquoter_long_ascii(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): UNQUOTER(LONG_QUERY) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed needs to be installed") -def test_unquoter_long_pct(benchmark: "BenchmarkFixture") -> None: +def test_unquoter_long_pct(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): diff --git a/tests/test_url_benchmarks.py b/tests/test_url_benchmarks.py index 541b5e81e..194092672 100644 --- a/tests/test_url_benchmarks.py +++ b/tests/test_url_benchmarks.py @@ -2,14 +2,10 @@ import pytest -try: - from pytest_codspeed import BenchmarkFixture +from yarl import URL - CODSPEED_MISSING = False -except ImportError: - CODSPEED_MISSING = True +pytest_codspeed = pytest.importorskip("pytest_codspeed") -from yarl import URL MANY_HOSTS = [f"www.domain{i}.tld" for i in range(256)] MANY_URLS = [f"https://www.domain{i}.tld" for i in range(256)] @@ -36,56 +32,59 @@ class _SubClassedStr(str): """A subclass of str that does nothing.""" -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_with_host_and_port(benchmark: "BenchmarkFixture") -> None: +def test_url_build_with_host_and_port( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): URL.build(host="www.domain.tld", path="/req", port=1234) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_with_simple_query(benchmark: "BenchmarkFixture") -> None: +def test_url_build_with_simple_query( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): URL.build(host="www.domain.tld", query=SIMPLE_QUERY) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_no_netloc(benchmark: "BenchmarkFixture") -> None: +def test_url_build_no_netloc(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): URL.build(path="/req/req/req") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_no_netloc_relative(benchmark: "BenchmarkFixture") -> None: +def test_url_build_no_netloc_relative( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): URL.build(path="req/req/req") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_encoded_with_host_and_port(benchmark: "BenchmarkFixture") -> None: +def test_url_build_encoded_with_host_and_port( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): URL.build(host="www.domain.tld", path="/req", port=1234, encoded=True) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_with_host(benchmark: "BenchmarkFixture") -> None: +def test_url_build_with_host(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): URL.build(host="domain") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_access_username_password(benchmark: "BenchmarkFixture") -> None: +def test_url_build_access_username_password( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): @@ -94,8 +93,9 @@ def _run() -> None: url.raw_password -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_access_raw_host(benchmark: "BenchmarkFixture") -> None: +def test_url_build_access_raw_host( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): @@ -103,8 +103,9 @@ def _run() -> None: url.raw_host -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_access_fragment(benchmark: "BenchmarkFixture") -> None: +def test_url_build_access_fragment( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): @@ -112,8 +113,9 @@ def _run() -> None: url.fragment -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_access_raw_path(benchmark: "BenchmarkFixture") -> None: +def test_url_build_access_raw_path( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): @@ -121,49 +123,51 @@ def _run() -> None: url.raw_path -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_with_different_hosts(benchmark: "BenchmarkFixture") -> None: +def test_url_build_with_different_hosts( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for host in MANY_HOSTS: URL.build(host=host) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_build_with_host_path_and_port(benchmark: "BenchmarkFixture") -> None: +def test_url_build_with_host_path_and_port( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): URL.build(host="www.domain.tld", port=1234) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_no_netloc(benchmark: "BenchmarkFixture") -> None: +def test_url_make_no_netloc(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): URL("/req/req/req") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_no_netloc_relative(benchmark: "BenchmarkFixture") -> None: +def test_url_make_no_netloc_relative( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): URL("req/req/req") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_host_path_and_port(benchmark: "BenchmarkFixture") -> None: +def test_url_make_with_host_path_and_port( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): URL("http://www.domain.tld:1234/req") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_encoded_with_host_path_and_port( - benchmark: "BenchmarkFixture", + benchmark: "pytest_codspeed.BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -171,40 +175,45 @@ def _run() -> None: URL("http://www.domain.tld:1234/req", encoded=True) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_host_and_path(benchmark: "BenchmarkFixture") -> None: +def test_url_make_with_host_and_path( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): URL("http://www.domain.tld") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_many_hosts(benchmark: "BenchmarkFixture") -> None: +def test_url_make_with_many_hosts( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for url in MANY_URLS: URL(url) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_many_ipv4_hosts(benchmark: "BenchmarkFixture") -> None: +def test_url_make_with_many_ipv4_hosts( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for url in MANY_IPV4_URLS: URL(url) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_many_ipv6_hosts(benchmark: "BenchmarkFixture") -> None: +def test_url_make_with_many_ipv6_hosts( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for url in MANY_IPV6_URLS: URL(url) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_access_raw_host(benchmark: "BenchmarkFixture") -> None: +def test_url_make_access_raw_host( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): @@ -212,8 +221,7 @@ def _run() -> None: url.raw_host -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_raw_host_empty_cache(benchmark: "BenchmarkFixture") -> None: +def test_raw_host_empty_cache(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: url = URL("http://www.domain.tld") @benchmark @@ -223,8 +231,9 @@ def _run() -> None: url.raw_host -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_access_fragment(benchmark: "BenchmarkFixture") -> None: +def test_url_make_access_fragment( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): @@ -232,8 +241,9 @@ def _run() -> None: url.fragment -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_access_raw_path(benchmark: "BenchmarkFixture") -> None: +def test_url_make_access_raw_path( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): @@ -241,8 +251,9 @@ def _run() -> None: url.raw_path -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_access_username_password(benchmark: "BenchmarkFixture") -> None: +def test_url_make_access_username_password( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): @@ -251,25 +262,22 @@ def _run() -> None: url.raw_password -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_empty_username(benchmark: "BenchmarkFixture") -> None: +def test_url_make_empty_username(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): URL("http://:password@www.domain.tld") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_empty_password(benchmark: "BenchmarkFixture") -> None: +def test_url_make_empty_password(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): URL("http://user:@www.domain.tld") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_with_ipv4_address_path_and_port( - benchmark: "BenchmarkFixture", + benchmark: "pytest_codspeed.BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -277,17 +285,17 @@ def _run() -> None: URL("http://127.0.0.1:1234/req") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_ipv4_address_and_path(benchmark: "BenchmarkFixture") -> None: +def test_url_make_with_ipv4_address_and_path( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): URL("http://127.0.0.1/req") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_make_with_ipv6_address_path_and_port( - benchmark: "BenchmarkFixture", + benchmark: "pytest_codspeed.BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -295,16 +303,18 @@ def _run() -> None: URL("http://[::1]:1234/req") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_make_with_ipv6_address_and_path(benchmark: "BenchmarkFixture") -> None: +def test_url_make_with_ipv6_address_and_path( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): URL("http://[::1]/req") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_extend_query_subclassed_str(benchmark: "BenchmarkFixture") -> None: +def test_extend_query_subclassed_str( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: """Test extending a query with a subclassed str.""" subclassed_query = {str(i): _SubClassedStr(i) for i in range(10)} @@ -314,57 +324,54 @@ def _run() -> None: BASE_URL.with_query(subclassed_query) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_with_query_mapping(benchmark: "BenchmarkFixture") -> None: +def test_with_query_mapping(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): BASE_URL.with_query(SIMPLE_QUERY) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_with_query_mapping_int_values(benchmark: "BenchmarkFixture") -> None: +def test_with_query_mapping_int_values( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(25): BASE_URL.with_query(SIMPLE_INT_QUERY) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_with_query_sequence_mapping(benchmark: "BenchmarkFixture") -> None: +def test_with_query_sequence_mapping( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(25): BASE_URL.with_query(QUERY_SEQ) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_with_query_empty(benchmark: "BenchmarkFixture") -> None: +def test_with_query_empty(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): BASE_URL.with_query({}) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_with_query_none(benchmark: "BenchmarkFixture") -> None: +def test_with_query_none(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): BASE_URL.with_query(None) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_update_query_mapping(benchmark: "BenchmarkFixture") -> None: +def test_update_query_mapping(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): BASE_URL.update_query(SIMPLE_QUERY) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_update_query_mapping_with_existing_query( - benchmark: "BenchmarkFixture", + benchmark: "pytest_codspeed.BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -372,49 +379,47 @@ def _run() -> None: QUERY_URL.update_query(SIMPLE_QUERY) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_update_query_sequence_mapping(benchmark: "BenchmarkFixture") -> None: +def test_update_query_sequence_mapping( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(25): BASE_URL.update_query(QUERY_SEQ) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_update_query_empty(benchmark: "BenchmarkFixture") -> None: +def test_update_query_empty(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): BASE_URL.update_query({}) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_update_query_none(benchmark: "BenchmarkFixture") -> None: +def test_update_query_none(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): BASE_URL.update_query(None) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_update_query_string(benchmark: "BenchmarkFixture") -> None: +def test_update_query_string(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): BASE_URL.update_query(QUERY_STRING) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_extend_query_simple_query_dict(benchmark: "BenchmarkFixture") -> None: +def test_url_extend_query_simple_query_dict( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(25): BASE_URL.extend_query(SIMPLE_QUERY) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") def test_url_extend_query_existing_query_simple_query_dict( - benchmark: "BenchmarkFixture", + benchmark: "pytest_codspeed.BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -422,104 +427,95 @@ def _run() -> None: QUERY_URL.extend_query(SIMPLE_QUERY) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_extend_query_existing_query_string(benchmark: "BenchmarkFixture") -> None: +def test_url_extend_query_existing_query_string( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(25): QUERY_URL.extend_query(QUERY_STRING) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_to_string(benchmark: "BenchmarkFixture") -> None: +def test_url_to_string(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): str(BASE_URL) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_path_to_string(benchmark: "BenchmarkFixture") -> None: +def test_url_with_path_to_string(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): str(URL_WITH_PATH) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_query_to_string(benchmark: "BenchmarkFixture") -> None: +def test_url_with_query_to_string( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): str(QUERY_URL) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_fragment(benchmark: "BenchmarkFixture") -> None: +def test_url_with_fragment(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.with_fragment("fragment") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_user(benchmark: "BenchmarkFixture") -> None: +def test_url_with_user(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.with_user("user") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_password(benchmark: "BenchmarkFixture") -> None: +def test_url_with_password(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.with_password("password") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_host(benchmark: "BenchmarkFixture") -> None: +def test_url_with_host(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.with_host("www.domain.tld") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_port(benchmark: "BenchmarkFixture") -> None: +def test_url_with_port(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.with_port(1234) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_scheme(benchmark: "BenchmarkFixture") -> None: +def test_url_with_scheme(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.with_scheme("https") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_name(benchmark: "BenchmarkFixture") -> None: +def test_url_with_name(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.with_name("other.tld") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_path(benchmark: "BenchmarkFixture") -> None: +def test_url_with_path(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.with_path("/req") -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_origin(benchmark: "BenchmarkFixture") -> None: +def test_url_origin(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @benchmark @@ -528,8 +524,9 @@ def _run() -> None: url.origin() -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_origin_with_user_pass(benchmark: "BenchmarkFixture") -> None: +def test_url_origin_with_user_pass( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: urls = [URL(URL_WITH_USER_PASS_STR) for _ in range(100)] @benchmark @@ -538,8 +535,7 @@ def _run() -> None: url.origin() -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_path_origin(benchmark: "BenchmarkFixture") -> None: +def test_url_with_path_origin(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: urls = [URL(URL_WITH_PATH_STR) for _ in range(100)] @benchmark @@ -548,16 +544,14 @@ def _run() -> None: url.origin() -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_path_relative(benchmark: "BenchmarkFixture") -> None: +def test_url_with_path_relative(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): URL_WITH_PATH.relative() -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_with_path_parent(benchmark: "BenchmarkFixture") -> None: +def test_url_with_path_parent(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: cache = URL_WITH_PATH._cache @benchmark @@ -567,24 +561,23 @@ def _run() -> None: URL_WITH_PATH.parent -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_join(benchmark: "BenchmarkFixture") -> None: +def test_url_join(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.join(REL_URL) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_joinpath_encoded(benchmark: "BenchmarkFixture") -> None: +def test_url_joinpath_encoded(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.joinpath("req", encoded=True) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_joinpath_encoded_long(benchmark: "BenchmarkFixture") -> None: +def test_url_joinpath_encoded_long( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): @@ -593,24 +586,23 @@ def _run() -> None: ) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_joinpath(benchmark: "BenchmarkFixture") -> None: +def test_url_joinpath(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.joinpath("req", encoded=False) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_joinpath_with_truediv(benchmark: "BenchmarkFixture") -> None: +def test_url_joinpath_with_truediv( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL / "req/req/req" -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_equality(benchmark: "BenchmarkFixture") -> None: +def test_url_equality(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -619,8 +611,7 @@ def _run() -> None: URL_WITH_PATH == URL_WITH_PATH -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_hash(benchmark: "BenchmarkFixture") -> None: +def test_url_hash(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: cache = BASE_URL._cache @benchmark @@ -630,8 +621,7 @@ def _run() -> None: hash(BASE_URL) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_is_default_port(benchmark: "BenchmarkFixture") -> None: +def test_is_default_port(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -639,8 +629,7 @@ def _run() -> None: URL_WITH_NOT_DEFAULT_PORT.is_default_port() -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_human_repr(benchmark: "BenchmarkFixture") -> None: +def test_human_repr(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -652,8 +641,7 @@ def _run() -> None: REL_URL.human_repr() -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_query_string(benchmark: "BenchmarkFixture") -> None: +def test_query_string(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: urls = [URL(QUERY_URL_STR) for _ in range(100)] @benchmark @@ -662,8 +650,7 @@ def _run() -> None: url.query_string -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_query_string(benchmark: "BenchmarkFixture") -> None: +def test_empty_query_string(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @benchmark @@ -672,8 +659,9 @@ def _run() -> None: url.query_string -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_query_string_uncached(benchmark: "BenchmarkFixture") -> None: +def test_empty_query_string_uncached( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @benchmark @@ -682,8 +670,7 @@ def _run() -> None: URL.query_string.wrapped(url) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_query(benchmark: "BenchmarkFixture") -> None: +def test_query(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: urls = [URL(QUERY_URL_STR) for _ in range(100)] @benchmark @@ -692,8 +679,7 @@ def _run() -> None: url.query -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_query(benchmark: "BenchmarkFixture") -> None: +def test_empty_query(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @benchmark @@ -702,8 +688,9 @@ def _run() -> None: url.query -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_url_host_port_subcomponent(benchmark: "BenchmarkFixture") -> None: +def test_url_host_port_subcomponent( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: cache_non_default = URL_WITH_NOT_DEFAULT_PORT._cache cache = BASE_URL._cache @@ -716,8 +703,7 @@ def _run() -> None: BASE_URL.host_port_subcomponent -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_path(benchmark: "BenchmarkFixture") -> None: +def test_empty_path(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: """Test accessing empty path.""" @benchmark @@ -726,8 +712,7 @@ def _run() -> None: BASE_URL.path -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_path_uncached(benchmark: "BenchmarkFixture") -> None: +def test_empty_path_uncached(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: """Test accessing empty path without cache.""" @benchmark @@ -736,8 +721,7 @@ def _run() -> None: URL.path.wrapped(BASE_URL) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_path_safe(benchmark: "BenchmarkFixture") -> None: +def test_empty_path_safe(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: """Test accessing empty path safe.""" @benchmark @@ -746,8 +730,9 @@ def _run() -> None: BASE_URL.path_safe -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_path_safe_uncached(benchmark: "BenchmarkFixture") -> None: +def test_empty_path_safe_uncached( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: """Test accessing empty path safe without cache.""" @benchmark @@ -756,8 +741,7 @@ def _run() -> None: URL.path_safe.wrapped(BASE_URL) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_path_safe(benchmark: "BenchmarkFixture") -> None: +def test_path_safe(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: """Test accessing path safe.""" @benchmark @@ -766,8 +750,7 @@ def _run() -> None: URL_WITH_PATH.path_safe -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_path_safe_uncached(benchmark: "BenchmarkFixture") -> None: +def test_path_safe_uncached(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: """Test accessing path safe without cache.""" @benchmark @@ -776,8 +759,7 @@ def _run() -> None: URL.path_safe.wrapped(URL_WITH_PATH) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_raw_path_qs(benchmark: "BenchmarkFixture") -> None: +def test_empty_raw_path_qs(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: """Test accessing empty raw path with query.""" @benchmark @@ -786,8 +768,9 @@ def _run() -> None: BASE_URL.raw_path_qs -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_empty_raw_path_qs_uncached(benchmark: "BenchmarkFixture") -> None: +def test_empty_raw_path_qs_uncached( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: """Test accessing empty raw path with query without cache.""" @benchmark @@ -796,8 +779,7 @@ def _run() -> None: URL.raw_path_qs.wrapped(BASE_URL) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_raw_path_qs(benchmark: "BenchmarkFixture") -> None: +def test_raw_path_qs(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: """Test accessing raw path qs without query.""" @benchmark @@ -806,8 +788,7 @@ def _run() -> None: URL_WITH_PATH.raw_path_qs -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_raw_path_qs_uncached(benchmark: "BenchmarkFixture") -> None: +def test_raw_path_qs_uncached(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: """Test accessing raw path qs without query and without cache.""" @benchmark @@ -816,8 +797,7 @@ def _run() -> None: URL.raw_path_qs.wrapped(URL_WITH_PATH) -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_raw_path_qs_with_query(benchmark: "BenchmarkFixture") -> None: +def test_raw_path_qs_with_query(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: """Test accessing raw path qs with query.""" @benchmark @@ -826,8 +806,9 @@ def _run() -> None: IPV6_QUERY_URL.raw_path_qs -@pytest.mark.skipif(CODSPEED_MISSING, reason="pytest-codspeed is not installed") -def test_raw_path_qs_with_query_uncached(benchmark: "BenchmarkFixture") -> None: +def test_raw_path_qs_with_query_uncached( + benchmark: "pytest_codspeed.BenchmarkFixture", +) -> None: """Test accessing raw path qs with query and without cache.""" @benchmark From 3c96278a7cfc41e2192a51bb2b0f02071c056c8c Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Mon, 17 Feb 2025 15:30:35 +0100 Subject: [PATCH 17/31] Update docs/spelling_wordlist.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) --- docs/spelling_wordlist.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index 95c9c5632..ffc162fb0 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -1,8 +1,8 @@ Bluesky Bugfixes -CPython Changelog Codecov +CPython Cython GPG IPv From f751f6a948033178f54c501cfaa872fb2d1f6a43 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 14:31:36 +0000 Subject: [PATCH 18/31] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/spelling_wordlist.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index ffc162fb0..95c9c5632 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -1,8 +1,8 @@ Bluesky Bugfixes +CPython Changelog Codecov -CPython Cython GPG IPv From df18f32fce4c6414d70f642d31546ca2d593e0e4 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Mon, 17 Feb 2025 15:32:36 +0100 Subject: [PATCH 19/31] Revert changes unrelated to free-threaded support --- .github/workflows/ci-cd.yml | 2 +- .github/workflows/reusable-linters.yml | 2 +- pytest.ini | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index a6b67987a..dcaa6a7a3 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -38,7 +38,7 @@ env: PY_COLORS: 1 # Recognized by the `py` package, dependency of `pytest` PYTHONIOENCODING: utf-8 PYTHONUTF8: 1 - PYTHON_LATEST: 3.13 + PYTHON_LATEST: 3.12 jobs: diff --git a/.github/workflows/reusable-linters.yml b/.github/workflows/reusable-linters.yml index e127ea23e..68b06d497 100644 --- a/.github/workflows/reusable-linters.yml +++ b/.github/workflows/reusable-linters.yml @@ -21,7 +21,7 @@ env: PY_COLORS: 1 # Recognized by the `py` package, dependency of `pytest` PYTHONIOENCODING: utf-8 PYTHONUTF8: 1 - PYTHON_LATEST: 3.13 + PYTHON_LATEST: 3.12 jobs: diff --git a/pytest.ini b/pytest.ini index 13670e14b..00e75faa7 100644 --- a/pytest.ini +++ b/pytest.ini @@ -39,7 +39,7 @@ doctest_optionflags = ALLOW_UNICODE ELLIPSIS # Marks tests with an empty parameterset as xfail(run=False) empty_parameter_set_mark = xfail -faulthandler_timeout = 60 +faulthandler_timeout = 30 filterwarnings = error @@ -80,7 +80,6 @@ norecursedirs = .github .tox *.egg - .hypothesis testpaths = tests/ From 40a8488c942eefb580caf63cb4745a5ff045485f Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Mon, 17 Feb 2025 15:42:51 +0100 Subject: [PATCH 20/31] Use pytestmark to fix mypy --- tests/test_quoting_benchmarks.py | 27 +++-- tests/test_url_benchmarks.py | 185 ++++++++++++++++--------------- 2 files changed, 109 insertions(+), 103 deletions(-) diff --git a/tests/test_quoting_benchmarks.py b/tests/test_quoting_benchmarks.py index 59a1b5da2..510e72517 100644 --- a/tests/test_quoting_benchmarks.py +++ b/tests/test_quoting_benchmarks.py @@ -2,9 +2,12 @@ import pytest -from yarl._quoting import _Quoter, _Unquoter +try: + from pytest_codspeed import BenchmarkFixture +except ImportError: + pytestmark = pytest.mark.skip("pytest-codspeed needs to be installed") -pytest_codspeed = pytest.importorskip("pytest_codspeed") +from yarl._quoting import _Quoter, _Unquoter QUOTER_SLASH_SAFE = _Quoter(safe="/") @@ -18,70 +21,70 @@ LONG_QUERY_WITH_PCT = LONG_QUERY + "&d=%25%2F%3F%3A%40%26%3B%3D%2B" -def test_quote_query_string(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_quote_query_string(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): QUERY_QUOTER("a=1&b=2&c=3&d=4&e=5&f=6&g=7&h=8&i=9&j=0") -def test_quoter_ascii(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_quoter_ascii(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): QUOTER_SLASH_SAFE("/path/to") -def test_quote_long_path(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_quote_long_path(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): PATH_QUOTER(LONG_PATH) -def test_quoter_pct(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_quoter_pct(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): QUOTER("abc%0a") -def test_long_query(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_long_query(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): QUERY_QUOTER(LONG_QUERY) -def test_long_query_with_pct(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_long_query_with_pct(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): QUERY_QUOTER(LONG_QUERY_WITH_PCT) -def test_quoter_quote_utf8(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_quoter_quote_utf8(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): PATH_QUOTER("/шлях/файл") -def test_unquoter_short(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_unquoter_short(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): UNQUOTER("/path/to") -def test_unquoter_long_ascii(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_unquoter_long_ascii(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): UNQUOTER(LONG_QUERY) -def test_unquoter_long_pct(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_unquoter_long_pct(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): diff --git a/tests/test_url_benchmarks.py b/tests/test_url_benchmarks.py index 194092672..ca852359f 100644 --- a/tests/test_url_benchmarks.py +++ b/tests/test_url_benchmarks.py @@ -2,9 +2,12 @@ import pytest -from yarl import URL +try: + from pytest_codspeed import BenchmarkFixture +except ImportError: + pytestmark = pytest.mark.skip("pytest-codspeed needs to be installed") -pytest_codspeed = pytest.importorskip("pytest_codspeed") +from yarl import URL MANY_HOSTS = [f"www.domain{i}.tld" for i in range(256)] @@ -33,7 +36,7 @@ class _SubClassedStr(str): def test_url_build_with_host_and_port( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -42,7 +45,7 @@ def _run() -> None: def test_url_build_with_simple_query( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -50,7 +53,7 @@ def _run() -> None: URL.build(host="www.domain.tld", query=SIMPLE_QUERY) -def test_url_build_no_netloc(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_build_no_netloc(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -58,7 +61,7 @@ def _run() -> None: def test_url_build_no_netloc_relative( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -67,7 +70,7 @@ def _run() -> None: def test_url_build_encoded_with_host_and_port( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -75,7 +78,7 @@ def _run() -> None: URL.build(host="www.domain.tld", path="/req", port=1234, encoded=True) -def test_url_build_with_host(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_build_with_host(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -83,7 +86,7 @@ def _run() -> None: def test_url_build_access_username_password( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -94,7 +97,7 @@ def _run() -> None: def test_url_build_access_raw_host( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -104,7 +107,7 @@ def _run() -> None: def test_url_build_access_fragment( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -114,7 +117,7 @@ def _run() -> None: def test_url_build_access_raw_path( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -124,7 +127,7 @@ def _run() -> None: def test_url_build_with_different_hosts( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -133,7 +136,7 @@ def _run() -> None: def test_url_build_with_host_path_and_port( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -141,7 +144,7 @@ def _run() -> None: URL.build(host="www.domain.tld", port=1234) -def test_url_make_no_netloc(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_make_no_netloc(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -149,7 +152,7 @@ def _run() -> None: def test_url_make_no_netloc_relative( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -158,7 +161,7 @@ def _run() -> None: def test_url_make_with_host_path_and_port( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -167,7 +170,7 @@ def _run() -> None: def test_url_make_encoded_with_host_path_and_port( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -176,7 +179,7 @@ def _run() -> None: def test_url_make_with_host_and_path( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -185,7 +188,7 @@ def _run() -> None: def test_url_make_with_many_hosts( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -194,7 +197,7 @@ def _run() -> None: def test_url_make_with_many_ipv4_hosts( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -203,7 +206,7 @@ def _run() -> None: def test_url_make_with_many_ipv6_hosts( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -212,7 +215,7 @@ def _run() -> None: def test_url_make_access_raw_host( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -221,7 +224,7 @@ def _run() -> None: url.raw_host -def test_raw_host_empty_cache(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_raw_host_empty_cache(benchmark: "BenchmarkFixture") -> None: url = URL("http://www.domain.tld") @benchmark @@ -232,7 +235,7 @@ def _run() -> None: def test_url_make_access_fragment( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -242,7 +245,7 @@ def _run() -> None: def test_url_make_access_raw_path( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -252,7 +255,7 @@ def _run() -> None: def test_url_make_access_username_password( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -262,14 +265,14 @@ def _run() -> None: url.raw_password -def test_url_make_empty_username(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_make_empty_username(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): URL("http://:password@www.domain.tld") -def test_url_make_empty_password(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_make_empty_password(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -277,7 +280,7 @@ def _run() -> None: def test_url_make_with_ipv4_address_path_and_port( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -286,7 +289,7 @@ def _run() -> None: def test_url_make_with_ipv4_address_and_path( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -295,7 +298,7 @@ def _run() -> None: def test_url_make_with_ipv6_address_path_and_port( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -304,7 +307,7 @@ def _run() -> None: def test_url_make_with_ipv6_address_and_path( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -313,7 +316,7 @@ def _run() -> None: def test_extend_query_subclassed_str( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: """Test extending a query with a subclassed str.""" subclassed_query = {str(i): _SubClassedStr(i) for i in range(10)} @@ -324,7 +327,7 @@ def _run() -> None: BASE_URL.with_query(subclassed_query) -def test_with_query_mapping(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_with_query_mapping(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): @@ -332,7 +335,7 @@ def _run() -> None: def test_with_query_mapping_int_values( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -341,7 +344,7 @@ def _run() -> None: def test_with_query_sequence_mapping( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -349,21 +352,21 @@ def _run() -> None: BASE_URL.with_query(QUERY_SEQ) -def test_with_query_empty(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_with_query_empty(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): BASE_URL.with_query({}) -def test_with_query_none(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_with_query_none(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): BASE_URL.with_query(None) -def test_update_query_mapping(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_update_query_mapping(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): @@ -371,7 +374,7 @@ def _run() -> None: def test_update_query_mapping_with_existing_query( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -380,7 +383,7 @@ def _run() -> None: def test_update_query_sequence_mapping( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -388,21 +391,21 @@ def _run() -> None: BASE_URL.update_query(QUERY_SEQ) -def test_update_query_empty(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_update_query_empty(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): BASE_URL.update_query({}) -def test_update_query_none(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_update_query_none(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): BASE_URL.update_query(None) -def test_update_query_string(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_update_query_string(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(25): @@ -410,7 +413,7 @@ def _run() -> None: def test_url_extend_query_simple_query_dict( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -419,7 +422,7 @@ def _run() -> None: def test_url_extend_query_existing_query_simple_query_dict( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -428,7 +431,7 @@ def _run() -> None: def test_url_extend_query_existing_query_string( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -436,14 +439,14 @@ def _run() -> None: QUERY_URL.extend_query(QUERY_STRING) -def test_url_to_string(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_to_string(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): str(BASE_URL) -def test_url_with_path_to_string(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_with_path_to_string(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -451,7 +454,7 @@ def _run() -> None: def test_url_with_query_to_string( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -459,63 +462,63 @@ def _run() -> None: str(QUERY_URL) -def test_url_with_fragment(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_with_fragment(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.with_fragment("fragment") -def test_url_with_user(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_with_user(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.with_user("user") -def test_url_with_password(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_with_password(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.with_password("password") -def test_url_with_host(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_with_host(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.with_host("www.domain.tld") -def test_url_with_port(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_with_port(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.with_port(1234) -def test_url_with_scheme(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_with_scheme(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.with_scheme("https") -def test_url_with_name(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_with_name(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.with_name("other.tld") -def test_url_with_path(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_with_path(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.with_path("/req") -def test_url_origin(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_origin(benchmark: "BenchmarkFixture") -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @benchmark @@ -525,7 +528,7 @@ def _run() -> None: def test_url_origin_with_user_pass( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: urls = [URL(URL_WITH_USER_PASS_STR) for _ in range(100)] @@ -535,7 +538,7 @@ def _run() -> None: url.origin() -def test_url_with_path_origin(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_with_path_origin(benchmark: "BenchmarkFixture") -> None: urls = [URL(URL_WITH_PATH_STR) for _ in range(100)] @benchmark @@ -544,14 +547,14 @@ def _run() -> None: url.origin() -def test_url_with_path_relative(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_with_path_relative(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): URL_WITH_PATH.relative() -def test_url_with_path_parent(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_with_path_parent(benchmark: "BenchmarkFixture") -> None: cache = URL_WITH_PATH._cache @benchmark @@ -561,14 +564,14 @@ def _run() -> None: URL_WITH_PATH.parent -def test_url_join(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_join(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): BASE_URL.join(REL_URL) -def test_url_joinpath_encoded(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_joinpath_encoded(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -576,7 +579,7 @@ def _run() -> None: def test_url_joinpath_encoded_long( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -586,7 +589,7 @@ def _run() -> None: ) -def test_url_joinpath(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_joinpath(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -594,7 +597,7 @@ def _run() -> None: def test_url_joinpath_with_truediv( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: @benchmark def _run() -> None: @@ -602,7 +605,7 @@ def _run() -> None: BASE_URL / "req/req/req" -def test_url_equality(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_equality(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -611,7 +614,7 @@ def _run() -> None: URL_WITH_PATH == URL_WITH_PATH -def test_url_hash(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_url_hash(benchmark: "BenchmarkFixture") -> None: cache = BASE_URL._cache @benchmark @@ -621,7 +624,7 @@ def _run() -> None: hash(BASE_URL) -def test_is_default_port(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_is_default_port(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -629,7 +632,7 @@ def _run() -> None: URL_WITH_NOT_DEFAULT_PORT.is_default_port() -def test_human_repr(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_human_repr(benchmark: "BenchmarkFixture") -> None: @benchmark def _run() -> None: for _ in range(100): @@ -641,7 +644,7 @@ def _run() -> None: REL_URL.human_repr() -def test_query_string(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_query_string(benchmark: "BenchmarkFixture") -> None: urls = [URL(QUERY_URL_STR) for _ in range(100)] @benchmark @@ -650,7 +653,7 @@ def _run() -> None: url.query_string -def test_empty_query_string(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_empty_query_string(benchmark: "BenchmarkFixture") -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @benchmark @@ -660,7 +663,7 @@ def _run() -> None: def test_empty_query_string_uncached( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @@ -670,7 +673,7 @@ def _run() -> None: URL.query_string.wrapped(url) -def test_query(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_query(benchmark: "BenchmarkFixture") -> None: urls = [URL(QUERY_URL_STR) for _ in range(100)] @benchmark @@ -679,7 +682,7 @@ def _run() -> None: url.query -def test_empty_query(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_empty_query(benchmark: "BenchmarkFixture") -> None: urls = [URL(BASE_URL_STR) for _ in range(100)] @benchmark @@ -689,7 +692,7 @@ def _run() -> None: def test_url_host_port_subcomponent( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: cache_non_default = URL_WITH_NOT_DEFAULT_PORT._cache cache = BASE_URL._cache @@ -703,7 +706,7 @@ def _run() -> None: BASE_URL.host_port_subcomponent -def test_empty_path(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_empty_path(benchmark: "BenchmarkFixture") -> None: """Test accessing empty path.""" @benchmark @@ -712,7 +715,7 @@ def _run() -> None: BASE_URL.path -def test_empty_path_uncached(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_empty_path_uncached(benchmark: "BenchmarkFixture") -> None: """Test accessing empty path without cache.""" @benchmark @@ -721,7 +724,7 @@ def _run() -> None: URL.path.wrapped(BASE_URL) -def test_empty_path_safe(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_empty_path_safe(benchmark: "BenchmarkFixture") -> None: """Test accessing empty path safe.""" @benchmark @@ -731,7 +734,7 @@ def _run() -> None: def test_empty_path_safe_uncached( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: """Test accessing empty path safe without cache.""" @@ -741,7 +744,7 @@ def _run() -> None: URL.path_safe.wrapped(BASE_URL) -def test_path_safe(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_path_safe(benchmark: "BenchmarkFixture") -> None: """Test accessing path safe.""" @benchmark @@ -750,7 +753,7 @@ def _run() -> None: URL_WITH_PATH.path_safe -def test_path_safe_uncached(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_path_safe_uncached(benchmark: "BenchmarkFixture") -> None: """Test accessing path safe without cache.""" @benchmark @@ -759,7 +762,7 @@ def _run() -> None: URL.path_safe.wrapped(URL_WITH_PATH) -def test_empty_raw_path_qs(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_empty_raw_path_qs(benchmark: "BenchmarkFixture") -> None: """Test accessing empty raw path with query.""" @benchmark @@ -769,7 +772,7 @@ def _run() -> None: def test_empty_raw_path_qs_uncached( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: """Test accessing empty raw path with query without cache.""" @@ -779,7 +782,7 @@ def _run() -> None: URL.raw_path_qs.wrapped(BASE_URL) -def test_raw_path_qs(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_raw_path_qs(benchmark: "BenchmarkFixture") -> None: """Test accessing raw path qs without query.""" @benchmark @@ -788,7 +791,7 @@ def _run() -> None: URL_WITH_PATH.raw_path_qs -def test_raw_path_qs_uncached(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_raw_path_qs_uncached(benchmark: "BenchmarkFixture") -> None: """Test accessing raw path qs without query and without cache.""" @benchmark @@ -797,7 +800,7 @@ def _run() -> None: URL.raw_path_qs.wrapped(URL_WITH_PATH) -def test_raw_path_qs_with_query(benchmark: "pytest_codspeed.BenchmarkFixture") -> None: +def test_raw_path_qs_with_query(benchmark: "BenchmarkFixture") -> None: """Test accessing raw path qs with query.""" @benchmark @@ -807,7 +810,7 @@ def _run() -> None: def test_raw_path_qs_with_query_uncached( - benchmark: "pytest_codspeed.BenchmarkFixture", + benchmark: "BenchmarkFixture", ) -> None: """Test accessing raw path qs with query and without cache.""" From bb5039b58d4f0fb7e6e363d109a40f34f5183e5a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 14:44:12 +0000 Subject: [PATCH 21/31] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_quoting_benchmarks.py | 1 - tests/test_url_benchmarks.py | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/test_quoting_benchmarks.py b/tests/test_quoting_benchmarks.py index 510e72517..8eb66011f 100644 --- a/tests/test_quoting_benchmarks.py +++ b/tests/test_quoting_benchmarks.py @@ -9,7 +9,6 @@ from yarl._quoting import _Quoter, _Unquoter - QUOTER_SLASH_SAFE = _Quoter(safe="/") QUOTER = _Quoter() UNQUOTER = _Unquoter() diff --git a/tests/test_url_benchmarks.py b/tests/test_url_benchmarks.py index ca852359f..6107459f0 100644 --- a/tests/test_url_benchmarks.py +++ b/tests/test_url_benchmarks.py @@ -9,7 +9,6 @@ from yarl import URL - MANY_HOSTS = [f"www.domain{i}.tld" for i in range(256)] MANY_URLS = [f"https://www.domain{i}.tld" for i in range(256)] MANY_IPV4_URLS = [f"http://127.0.0.{i}" for i in range(256)] From dd07bfd477e20dcb30699bdb3c859bd36375489f Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Mon, 17 Feb 2025 18:23:26 +0100 Subject: [PATCH 22/31] Pin cython in the requirements file --- requirements/cython.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/cython.txt b/requirements/cython.txt index 8320af396..3eaca1624 100644 --- a/requirements/cython.txt +++ b/requirements/cython.txt @@ -1 +1 @@ -cython~=3.0.11 +cython==3.0.11 From 3527edc4bbbfd7461af2ae782398a4f570297041 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Mon, 17 Feb 2025 18:50:10 +0100 Subject: [PATCH 23/31] Separate cython constraint for free-threading --- pyproject.toml | 15 +++++++++------ requirements/cython-freethreading.txt | 1 + requirements/test-freethreading.txt | 2 ++ requirements/test-pure.txt | 8 ++++++++ requirements/test.txt | 9 +-------- 5 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 requirements/cython-freethreading.txt create mode 100644 requirements/test-freethreading.txt create mode 100644 requirements/test-pure.txt diff --git a/pyproject.toml b/pyproject.toml index 6b640c435..5a4d0b50a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,12 +79,6 @@ test-command = 'pytest -v -m "not hypothesis" --no-cov {project}/tests' # don't build PyPy wheels, install from source instead skip = "pp*" -# TODO: Remove this when there's a Cython 3.1 final release -# Remove PIP_CONSTRAINT from the environment -[[tool.cibuildwheel.overrides]] -select = "cp313t-*" -environment = {COLOR="yes", FORCE_COLOR="1", MYPY_FORCE_COLOR="1", PRE_COMMIT_COLOR="always", PY_COLORS="1"} - [tool.cibuildwheel.environment] COLOR = "yes" FORCE_COLOR = "1" @@ -98,3 +92,12 @@ pure-python = "false" [tool.cibuildwheel.windows] before-test = [] # Windows cmd has different syntax and pip chooses wheels + +# TODO: Remove this when there's a Cython 3.1 final release +# Remove PIP_CONSTRAINT from the environment +[[tool.cibuildwheel.overrides]] +select = "cp313t-*" + +test-requires = "-r requirements/test-freethreading.txt" +inherit.environment = "append" +environment = {PIP_CONSTRAINT = "requirements/cython-freethreading.txt"} diff --git a/requirements/cython-freethreading.txt b/requirements/cython-freethreading.txt new file mode 100644 index 000000000..b71204d42 --- /dev/null +++ b/requirements/cython-freethreading.txt @@ -0,0 +1 @@ +cython==3.1.0a1 diff --git a/requirements/test-freethreading.txt b/requirements/test-freethreading.txt new file mode 100644 index 000000000..5919a29f2 --- /dev/null +++ b/requirements/test-freethreading.txt @@ -0,0 +1,2 @@ +-r cython-freethreading.txt +-r test-pure.txt diff --git a/requirements/test-pure.txt b/requirements/test-pure.txt new file mode 100644 index 000000000..ed8d679c1 --- /dev/null +++ b/requirements/test-pure.txt @@ -0,0 +1,8 @@ +covdefaults +hypothesis>=6.0 +idna==3.10 +multidict==6.1.0 +propcache==0.2.1 +pytest==8.3.4 +pytest-cov>=2.3.1 +pytest-xdist diff --git a/requirements/test.txt b/requirements/test.txt index fb2f3647f..488873604 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,9 +1,2 @@ -r cython.txt -covdefaults -hypothesis>=6.0 -idna==3.10 -multidict==6.1.0 -propcache==0.2.1 -pytest==8.3.4 -pytest-cov>=2.3.1 -pytest-xdist +-r test-pure.txt From 794b0c6723a2130ea50a35bc75b00fb978c9befe Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 20 Feb 2025 16:19:47 -0600 Subject: [PATCH 24/31] Sync pytest-codspeed version with master --- requirements/codspeed.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/codspeed.txt b/requirements/codspeed.txt index 52d96f495..25cc17222 100644 --- a/requirements/codspeed.txt +++ b/requirements/codspeed.txt @@ -1,2 +1,2 @@ -r test.txt -pytest-codspeed==3.1.2 +pytest-codspeed==3.2.0 From d0813fd93a1fa8afcce5408a8e0c12c2320ee816 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 20 Feb 2025 16:19:59 -0600 Subject: [PATCH 25/31] Sync Cython version with master --- packaging/pep517_backend/_backend.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/pep517_backend/_backend.py b/packaging/pep517_backend/_backend.py index 9bbd31f48..d5e4f7cdf 100644 --- a/packaging/pep517_backend/_backend.py +++ b/packaging/pep517_backend/_backend.py @@ -377,7 +377,7 @@ def get_requires_for_build_wheel( elif sysconfig.get_config_var('Py_GIL_DISABLED'): c_ext_build_deps = ['Cython ~= 3.1.0a1'] else: - c_ext_build_deps = ['Cython ~= 3.0.11'] + c_ext_build_deps = ['Cython ~= 3.0.12'] return _setuptools_get_requires_for_build_wheel( config_settings=config_settings, From 0ab829dccaab7f266714172305bc9ee0a2927299 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Tue, 25 Feb 2025 14:41:20 +0100 Subject: [PATCH 26/31] Only avoid global buffer under the free-threaded build --- yarl/_quoting_c.pyx | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/yarl/_quoting_c.pyx b/yarl/_quoting_c.pyx index 6fed3926f..e3e18eb4b 100644 --- a/yarl/_quoting_c.pyx +++ b/yarl/_quoting_c.pyx @@ -13,6 +13,7 @@ from cpython.unicode cimport ( from libc.stdint cimport uint8_t, uint64_t from libc.string cimport memcpy, memset +import sysconfig from string import ascii_letters, digits @@ -25,6 +26,7 @@ cdef str ALLOWED = UNRESERVED + SUB_DELIMS_WITHOUT_QS cdef str QS = '+&=;' DEF BUF_SIZE = 8 * 1024 # 8KiB +cdef char BUFFER[BUF_SIZE] cdef inline Py_UCS4 _to_hex(uint8_t v) noexcept: if v < 10: @@ -90,18 +92,23 @@ cdef struct Writer: cdef inline void _init_writer(Writer* writer): - cdef char *buf = PyMem_Malloc(BUF_SIZE) - if buf == NULL: - PyErr_NoMemory() - return - writer.buf = buf + cdef char *buf + if sysconfig.get_config_var("Py_GIL_DISABLED"): + buf = PyMem_Malloc(BUF_SIZE) + if buf == NULL: + PyErr_NoMemory() + return + writer.buf = buf + else: + writer.buf = &BUFFER[0] writer.size = BUF_SIZE writer.pos = 0 writer.changed = 0 cdef inline void _release_writer(Writer* writer): - PyMem_Free(writer.buf) + if writer.buf != BUFFER: + PyMem_Free(writer.buf) cdef inline int _write_char(Writer* writer, Py_UCS4 ch, bint changed): @@ -111,10 +118,17 @@ cdef inline int _write_char(Writer* writer, Py_UCS4 ch, bint changed): if writer.pos == writer.size: # reallocate size = writer.size + BUF_SIZE - buf = PyMem_Realloc(writer.buf, size) - if buf == NULL: - PyErr_NoMemory() - return -1 + if writer.buf == BUFFER: + buf = PyMem_Malloc(size) + if buf == NULL: + PyErr_NoMemory() + return -1 + memcpy(buf, writer.buf, writer.size) + else: + buf = PyMem_Realloc(writer.buf, size) + if buf == NULL: + PyErr_NoMemory() + return -1 writer.buf = buf writer.size = size writer.buf[writer.pos] = ch From 95de33c0e1596ca3ec9f692028bdd2b83853a8bf Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Tue, 25 Feb 2025 15:29:53 +0100 Subject: [PATCH 27/31] Make a global out of sysconfig call --- yarl/_quoting_c.pyx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/yarl/_quoting_c.pyx b/yarl/_quoting_c.pyx index e3e18eb4b..eefd9bd3c 100644 --- a/yarl/_quoting_c.pyx +++ b/yarl/_quoting_c.pyx @@ -27,6 +27,7 @@ cdef str QS = '+&=;' DEF BUF_SIZE = 8 * 1024 # 8KiB cdef char BUFFER[BUF_SIZE] +cdef bint IS_GIL_DISABLED = sysconfig.get_config_var("Py_GIL_DISABLED") cdef inline Py_UCS4 _to_hex(uint8_t v) noexcept: if v < 10: @@ -93,7 +94,8 @@ cdef struct Writer: cdef inline void _init_writer(Writer* writer): cdef char *buf - if sysconfig.get_config_var("Py_GIL_DISABLED"): + if IS_GIL_DISABLED: + print("Calling malloc...") buf = PyMem_Malloc(BUF_SIZE) if buf == NULL: PyErr_NoMemory() From 8b896726b8bd5b740bd4563a70961ba026168361 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Tue, 25 Feb 2025 15:40:49 +0100 Subject: [PATCH 28/31] Update yarl/_quoting_c.pyx Co-authored-by: J. Nick Koston --- yarl/_quoting_c.pyx | 1 - 1 file changed, 1 deletion(-) diff --git a/yarl/_quoting_c.pyx b/yarl/_quoting_c.pyx index eefd9bd3c..5b35fff88 100644 --- a/yarl/_quoting_c.pyx +++ b/yarl/_quoting_c.pyx @@ -95,7 +95,6 @@ cdef struct Writer: cdef inline void _init_writer(Writer* writer): cdef char *buf if IS_GIL_DISABLED: - print("Calling malloc...") buf = PyMem_Malloc(BUF_SIZE) if buf == NULL: PyErr_NoMemory() From 72f1a8f659d67db7169c49d4f3c79092150d7bb6 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Tue, 11 Mar 2025 12:42:53 +0100 Subject: [PATCH 29/31] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) --- tests/test_quoting_benchmarks.py | 2 +- tests/test_url_benchmarks.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_quoting_benchmarks.py b/tests/test_quoting_benchmarks.py index 8eb66011f..5e66123af 100644 --- a/tests/test_quoting_benchmarks.py +++ b/tests/test_quoting_benchmarks.py @@ -4,7 +4,7 @@ try: from pytest_codspeed import BenchmarkFixture -except ImportError: +except ImportError: # pragma: no branch # only hit in cibuildwheel pytestmark = pytest.mark.skip("pytest-codspeed needs to be installed") from yarl._quoting import _Quoter, _Unquoter diff --git a/tests/test_url_benchmarks.py b/tests/test_url_benchmarks.py index 6107459f0..3847dc422 100644 --- a/tests/test_url_benchmarks.py +++ b/tests/test_url_benchmarks.py @@ -4,7 +4,7 @@ try: from pytest_codspeed import BenchmarkFixture -except ImportError: +except ImportError: # pragma: no branch # only hit in cibuildwheel pytestmark = pytest.mark.skip("pytest-codspeed needs to be installed") from yarl import URL From ec328c3232b37def3adb8d063190822feae3ff4c Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Tue, 11 Mar 2025 12:54:25 +0100 Subject: [PATCH 30/31] Install free-threading dependencies in CI/CD when running under 3.13t --- .github/workflows/ci-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 84613e54d..2e6352d34 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -258,7 +258,7 @@ jobs: - name: Install dependencies uses: py-actions/py-dependency-install@v4 with: - path: requirements/codspeed.txt + path: requirements/test${{ matrix.pyver == '3.13t' && '-freethreading' || '' }}.txt - name: Determine pre-compiled compatible wheel env: # NOTE: When `pip` is forced to colorize output piped into `jq`, From ace56a42ef65b2a49b0e8707645f23a065005448 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Tue, 11 Mar 2025 13:06:22 +0100 Subject: [PATCH 31/31] Fix coverage flags --- .github/workflows/ci-cd.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 2e6352d34..82de1a95c 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -258,7 +258,10 @@ jobs: - name: Install dependencies uses: py-actions/py-dependency-install@v4 with: - path: requirements/test${{ matrix.pyver == '3.13t' && '-freethreading' || '' }}.txt + path: >- + requirements/test${{ + matrix.pyver == '3.13t' && '-freethreading' || '' + }}.txt - name: Determine pre-compiled compatible wheel env: # NOTE: When `pip` is forced to colorize output piped into `jq`, @@ -372,7 +375,8 @@ jobs: pytest, OS-${{ runner.os }}, VM-${{ matrix.os }}, - Py-${{ steps.python-install.outputs.python-version }} + Py-${{ steps.python-install.outputs.python-version }}${{ + matrix.pyver == '3.13t' && 't' || '' }} fail_ci_if_error: true benchmark: