Skip to content

Commit

Permalink
Separate codspeed from test requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
lysnikolaou committed Jan 23, 2025
1 parent 129c3cd commit 9b669a8
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
1 change: 1 addition & 0 deletions docs/spelling_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Bluesky
Bugfixes
Changelog
Codecov
CPython
Cython
GPG
IPv
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions requirements/codspeed.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-r test.txt
pytest-codspeed==3.1.2
1 change: 0 additions & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ propcache==0.2.1
pytest==8.3.4
pytest-cov>=2.3.1
pytest-xdist
pytest_codspeed==3.1.0
17 changes: 16 additions & 1 deletion tests/test_quoting_benchmarks.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -15,69 +20,79 @@
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:
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(BenchmarkFixture is None, reason="pytest-codspeed needs to be installed")
def test_quoter_ascii(benchmark: BenchmarkFixture) -> None:
@benchmark
def _run() -> None:
for _ in range(100):
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:
for _ in range(100):
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:
for _ in range(100):
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:
for _ in range(100):
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:
for _ in range(100):
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:
for _ in range(100):
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:
for _ in range(100):
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:
for _ in range(100):
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:
Expand Down
Loading

0 comments on commit 9b669a8

Please sign in to comment.