DEV Community

anatlavitzkovitz
anatlavitzkovitz

Posted on

osdc-2023-assignment8

Running local tests

assignment 8
I cloned requests git, build a docker and run the tests, follwing this link:

git clone git@github.com:psf/requests.git
docker run -it --rm --workdir /opt -v$(pwd):/opt python:3.11 bash
pip install -r requirements-dev.txt
pip install tox
make test
Enter fullscreen mode Exit fullscreen mode

this is the print:

tox -p
py38-use_chardet_on_py3: SKIP ⚠ in 0.3 seconds
py37-default: SKIP ⚠ in 0.33 seconds
py38-default: SKIP ⚠ in 0.36 seconds
py310-use_chardet_on_py3: SKIP ⚠ in 0.37 seconds
py37-use_chardet_on_py3: SKIP ⚠ in 0.39 seconds
py310-default: SKIP ⚠ in 0.38 seconds
⠴ [4/10] py39-default | py39-use_chardet_on_py3 | py311-default | py311-use_chardet_on_py3
⠧ [4/10] py39-default | py39-use_chardet_on_py3 | py311-default | py311-use_chardet_on_py3
py39-default: OK ✔ in 1 minute 32.45 seconds
py39-use_chardet_on_py3: OK ✔ in 1 minute 32.68 seconds
py311-default: OK ✔ in 1 minute 32.79 seconds
py37-default: SKIP (0.32 seconds)
py37-use_chardet_on_py3: SKIP (0.39 seconds)
py38-default: SKIP (0.36 seconds)
py38-use_chardet_on_py3: SKIP (0.30 seconds)
py39-default: OK (92.44=setup[19.63]+cmd[72.81] seconds)
py39-use_chardet_on_py3: OK (92.68=setup[19.59]+cmd[73.09] seconds)
py310-default: SKIP (0.35 seconds)
py310-use_chardet_on_py3: SKIP (0.36 seconds)
py311-default: OK (92.79=setup[19.96]+cmd[72.83] seconds)
py311-use_chardet_on_py3: OK (92.90=setup[20.11]+cmd[72.79] seconds)
congratulations :) (92.99 seconds)

next:

pip install pytest-random-order pytest-coverage
pytest -svv --random-order --cov-config .coveragerc --cov=requests --cov-report html --cov-report term --cov-branch
Enter fullscreen mode Exit fullscreen mode

This is the result:

---------- coverage: platform linux, python 3.11.2-final-0 -----------

Name Stmts Miss Branch BrPart Cover

requests/init.py 68 68 10 0 0%
requests/version.py 10 10 0 0 0%
requests/_internal_utils.py 21 11 2 0 52%
requests/adapters.py 216 62 78 8 76%
requests/api.py 19 12 2 0 43%
requests/auth.py 173 53 60 15 70%
requests/certs.py 4 4 2 0 0%
requests/compat.py 30 30 2 0 0%
requests/cookies.py 239 116 104 9 52%
requests/exceptions.py 37 29 2 0 26%
requests/help.py 62 20 18 5 59%
requests/hooks.py 14 3 10 0 88%
requests/models.py 456 121 212 18 76%
requests/packages.py 17 17 10 0 0%
requests/sessions.py 268 61 100 4 82%
requests/status_codes.py 14 14 10 0 0%
requests/structures.py 39 18 8 0 62%

requests/utils.py 485 158 224 12 71%

TOTAL 2172 807 854 71 66%
Coverage HTML written to dir htmlcov


class notes:

My last change in author name will not be shown in pydigger, because it takes the data from pypi and not from github.

Webhooks:
whenever there is a change, github sends a json file with an update. updates the website with new slides with every push.
You can add a url via settings.
This can be set that only if github actions works, the slides are updated.

stash

What if I have some local changes but I need to pull the last version? start from the beginning? I can save my changes with stash, pull the repo and than pop the stashed data. how?

git stash  # saves local changes on the side.
git pull
git stash pop  #takes the last change and adds or number. if there is no conflict, it will be deleted.
git stash list
git stash show (0/1) #shows the last
Enter fullscreen mode Exit fullscreen mode

patch is the same as diff
git stash drop 0 # will through away 0

docker

docker image: playground
How to build a docker image and publish it in dockerhub?

docker login
docker build -t szabgab/playground:latest #build an image from a docker file
docker push #push to dockerhub
Enter fullscreen mode Exit fullscreen mode

This will first search locally for an image, or will pull from dockerhub if doesn't exist:

docker run -it -rm ...szabgab/playground:latest # pulls from dockerhub
Enter fullscreen mode Exit fullscreen mode

run python tests localy

Gabor cloned python requests.

jinja - a good example for a good repo (same as flask)

Gabor has a dev.to on this with a docker image run command.
via .github/actions you can understand how to run the test.
runs a make.
goto makfile.

make test #- dosent work
make
pytest test #-random_order #will run in a random order.
```




Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
szabgab profile image
Gabor Szabo

That's nice, but maybe you could do it with some other project, besides requests, describe how it is done there.