Skip to content

Commit

Permalink
Replace custom pytest reporter with pytest-pretty; upgrade deps
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Jun 11, 2024
1 parent d02421f commit 66b0c38
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 50 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
runs-on: ${{ matrix.os }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COLUMNS: 120
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -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
Expand Down
32 changes: 17 additions & 15 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions requirements/dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ po2json
pre-commit
ptpython
pylint
pytest-icdiff
pyupgrade
reformat-gherkin
ruff
Expand Down
26 changes: 16 additions & 10 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SHA1:207fc32547b0dca4f38f3f6edbc1d2721d8dc120
# SHA1:14fee5cb8c45d2a185aff044a2a6f2ab33b843b4
#
# This file is autogenerated by pip-compile-multi
# To update, run:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions requirements/test.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pytest-cov
pytest-dotenv
pytest-env
pytest-playwright
pytest-pretty
pytest-rerunfailures
pytest-socket
requests-mock
Expand Down
7 changes: 5 additions & 2 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SHA1:53380f1a9e10714a4d23fbf55796f24dc0f348d8
# SHA1:dac340f8dc887dbdd931039a6a45ccc5c68e1ae4
#
# This file is autogenerated by pip-compile-multi
# To update, run:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
21 changes: 0 additions & 21 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------------------------------------------


Expand Down

0 comments on commit 66b0c38

Please sign in to comment.