From 66b0c38e1f5f6acdbb936f5797bf03605c759dc3 Mon Sep 17 00:00:00 2001 From: Kiran Jonnalagadda Date: Tue, 11 Jun 2024 12:57:03 +0530 Subject: [PATCH] Replace custom pytest reporter with pytest-pretty; upgrade deps --- .github/workflows/pytest.yml | 5 +++-- requirements/base.txt | 32 +++++++++++++++++--------------- requirements/dev.in | 1 + requirements/dev.txt | 26 ++++++++++++++++---------- requirements/test.in | 1 + requirements/test.txt | 7 +++++-- tests/conftest.py | 21 --------------------- 7 files changed, 43 insertions(+), 50 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 22b56bf67..8f95d151f 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -32,6 +32,7 @@ jobs: runs-on: ${{ matrix.os }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COLUMNS: 120 strategy: fail-fast: false matrix: @@ -127,11 +128,11 @@ jobs: psql -h localhost -U postgres geoname_testing -c "grant all privileges on schema public to $(whoami); grant all privileges on all tables in schema public to $(whoami); grant all privileges on all sequences in schema public to $(whoami);" - name: Test with pytest run: | - pytest --disable-warnings --gherkin-terminal-reporter -vv --showlocals --ignore=tests/e2e + pytest --showlocals --ignore=tests/e2e --cov=funnel - name: Browser tests with pytest timeout-minutes: 5 run: | - pytest --disable-warnings --gherkin-terminal-reporter -vv --showlocals --cov-append --cov=funnel tests/e2e + pytest --showlocals --cov-append --cov=funnel tests/e2e - name: Prepare coverage report run: | mkdir -p coverage diff --git a/requirements/base.txt b/requirements/base.txt index 3594e2915..f28763397 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -66,7 +66,7 @@ cachelib==0.9.0 # via flask-caching cachetools==5.3.3 # via premailer -certifi==2024.2.2 +certifi==2024.6.2 # via # httpcore # httpx @@ -88,15 +88,15 @@ click==8.1.7 # rq crontab==1.0.1 # via rq-scheduler -cryptography==42.0.7 +cryptography==42.0.8 # via -r requirements/base.in cssmin==0.2.0 # via baseframe cssselect==1.2.0 # via premailer -cssutils==2.11.0 +cssutils==2.11.1 # via premailer -dataclasses-json==0.6.6 +dataclasses-json==0.6.7 # via -r requirements/base.in dnspython==2.6.1 # via @@ -213,7 +213,7 @@ idna==3.7 # requests # tldextract # yarl -ijson==3.2.3 +ijson==3.3.0 # via -r requirements/base.in isoweek==1.3.3 # via coaster @@ -254,14 +254,16 @@ markupsafe==2.1.5 # mako # werkzeug # wtforms -marshmallow==3.21.2 +marshmallow==3.21.3 # via dataclasses-json -maxminddb==2.6.1 +maxminddb==2.6.2 # via geoip2 mdit-py-plugins==0.4.1 # via -r requirements/base.in mdurl==0.1.2 # via markdown-it-py +more-itertools==10.3.0 + # via cssutils multidict==6.0.5 # via # aiohttp @@ -278,14 +280,14 @@ oauthlib==3.2.2 # tweepy orderedmultidict==1.0.1 # via furl -packaging==24.0 +packaging==24.1 # via # gunicorn # lazy-loader # marshmallow passlib==1.7.4 # via -r requirements/base.in -phonenumbers==8.13.37 +phonenumbers==8.13.38 # via -r requirements/base.in playwright==1.44.0 # via -r requirements/base.in @@ -304,7 +306,7 @@ pyasn1==0.6.0 # rsa pyasn1-modules==0.4.0 # via oauth2client -pycountry==23.12.11 +pycountry==24.6.1 # via # -r requirements/base.in # baseframe @@ -339,7 +341,7 @@ python-dateutil==2.9.0.post0 # rq-scheduler python-dotenv==1.0.1 # via -r requirements/base.in -python-telegram-bot==21.2 +python-telegram-bot==21.3 # via -r requirements/base.in python-utils==3.8.2 # via progressbar2 @@ -358,7 +360,7 @@ pyyaml==6.0.1 # pymdown-extensions qrcode==7.4.2 # via -r requirements/base.in -redis==5.0.4 +redis==5.0.5 # via # baseframe # flask-redis @@ -404,7 +406,7 @@ semantic-version==2.10.0 # via # baseframe # coaster -sentry-sdk==2.3.1 +sentry-sdk==2.5.1 # via baseframe six==1.16.0 # via @@ -447,11 +449,11 @@ tuspy==1.0.3 # via pyvimeo tweepy==4.14.0 # via -r requirements/base.in -twilio==9.1.0 +twilio==9.1.1 # via -r requirements/base.in types-python-dateutil==2.9.0.20240316 # via arrow -typing-extensions==4.12.0 +typing-extensions==4.12.2 # via # -r requirements/base.in # alembic diff --git a/requirements/dev.in b/requirements/dev.in index 19a4e8f2d..2dfbd24fd 100644 --- a/requirements/dev.in +++ b/requirements/dev.in @@ -8,6 +8,7 @@ po2json pre-commit ptpython pylint +pytest-icdiff pyupgrade reformat-gherkin ruff diff --git a/requirements/dev.txt b/requirements/dev.txt index 85049edf2..83fc22745 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,4 +1,4 @@ -# SHA1:207fc32547b0dca4f38f3f6edbc1d2721d8dc120 +# SHA1:14fee5cb8c45d2a185aff044a2a6f2ab33b843b4 # # This file is autogenerated by pip-compile-multi # To update, run: @@ -30,6 +30,8 @@ flask-debugtoolbar==0.15.1 # via -r requirements/dev.in gherkin-official==24.0.0 # via reformat-gherkin +icdiff==2.0.7 + # via pytest-icdiff identify==2.5.36 # via pre-commit isort==5.13.2 @@ -44,11 +46,11 @@ mypy==1.10.0 # via -r requirements/dev.in mypy-json-report==1.2.0 # via -r requirements/dev.in -nodeenv==1.9.0 +nodeenv==1.9.1 # via pre-commit parso==0.8.4 # via jedi -pip-compile-multi==2.6.3 +pip-compile-multi==2.6.4 # via -r requirements/dev.in pip-tools==7.4.1 # via pip-compile-multi @@ -58,23 +60,27 @@ platformdirs==4.2.2 # virtualenv po2json==0.2.2 # via -r requirements/dev.in +pprintpp==0.4.0 + # via pytest-icdiff pre-commit==3.7.1 # via -r requirements/dev.in -prompt-toolkit==3.0.45 +prompt-toolkit==3.0.47 # via ptpython ptpython==3.0.27 # via -r requirements/dev.in -pylint==3.2.2 +pylint==3.2.3 # via -r requirements/dev.in pyproject-hooks==1.1.0 # via # build # pip-tools -pyupgrade==3.15.2 +pytest-icdiff==0.9 + # via -r requirements/dev.in +pyupgrade==3.16.0 # via -r requirements/dev.in reformat-gherkin==3.0.1 # via -r requirements/dev.in -ruff==0.4.6 +ruff==0.4.8 # via -r requirements/dev.in tokenize-rt==5.2.0 # via pyupgrade @@ -94,7 +100,7 @@ types-flask-migrate==4.0.0.20240311 # via -r requirements/dev.in types-geoip2==3.0.0 # via -r requirements/dev.in -types-greenlet==3.0.0.20240311 +types-greenlet==3.0.0.20240604 # via -r requirements/dev.in types-html5lib==1.1.11.20240228 # via types-beautifulsoup4 @@ -120,13 +126,13 @@ types-pyyaml==6.0.12.20240311 # via -r requirements/dev.in types-redis==4.6.0.20240425 # via -r requirements/dev.in -types-requests==2.32.0.20240523 +types-requests==2.32.0.20240602 # via -r requirements/dev.in types-setuptools==70.0.0.20240524 # via types-cffi types-zxcvbn==4.4.1.20240106 # via -r requirements/dev.in -ubelt==1.3.5 +ubelt==1.3.6 # via mkinit virtualenv==20.26.2 # via pre-commit diff --git a/requirements/test.in b/requirements/test.in index 8685f2415..7625375a8 100644 --- a/requirements/test.in +++ b/requirements/test.in @@ -10,6 +10,7 @@ pytest-cov pytest-dotenv pytest-env pytest-playwright +pytest-pretty pytest-rerunfailures pytest-socket requests-mock diff --git a/requirements/test.txt b/requirements/test.txt index fcbebb1aa..4b11042be 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,4 +1,4 @@ -# SHA1:53380f1a9e10714a4d23fbf55796f24dc0f348d8 +# SHA1:dac340f8dc887dbdd931039a6a45ccc5c68e1ae4 # # This file is autogenerated by pip-compile-multi # To update, run: @@ -25,7 +25,7 @@ docopt==0.6.2 # via coveralls iniconfig==2.0.0 # via pytest -parse==1.20.1 +parse==1.20.2 # via # parse-type # pytest-bdd @@ -43,6 +43,7 @@ pytest==8.0.0 # pytest-dotenv # pytest-env # pytest-playwright + # pytest-pretty # pytest-rerunfailures # pytest-socket pytest-asyncio==0.23.7 @@ -59,6 +60,8 @@ pytest-env==1.1.3 # via -r requirements/test.in pytest-playwright==0.5.0 # via -r requirements/test.in +pytest-pretty==1.2.0 + # via -r requirements/test.in pytest-rerunfailures==14.0 # via -r requirements/test.in pytest-socket==0.7.0 diff --git a/tests/conftest.py b/tests/conftest.py index 09f3ded48..2b9d62fbb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -130,27 +130,6 @@ def pytest_runtest_call(item: pytest.Function) -> None: typeguard.check_type(item.funcargs[attr], type_) -def pytest_runtest_logreport(report: pytest.TestReport) -> None: - """Add line numbers to log report, for easier discovery in code editors.""" - # Report location of test (failing line number if available, else test location) - filename, line_no, domain = report.location - if ( - report.longrepr is not None - and (repr_traceback := getattr(report.longrepr, 'reprtraceback', None)) - is not None - and (repr_file_loc := repr_traceback.reprentries[0].reprfileloc).path - == filename - ): - line_no = repr_file_loc.lineno - if report.nodeid.startswith(filename): - # Only insert a line number if the existing `nodeid`` refers to the same - # filename. Needed for pytest-bdd, which constructs tests and refers the - # filename that imported the scenario. This file will not have the actual test - # function, so no line number reference is possible; the `filename` in the - # report will refer to pytest-bdd internals - report.nodeid = f'{filename}:{line_no}::{domain}' - - # MARK: Playwright browser config ------------------------------------------------------