PYPROGLIB Telegram 5899
⚙️ Как настроить автоматическое тестирование с pytest и GitHub Actions

Настроим автоматическое выполнение тестов каждый раз при обновлении кода.

1⃣ Установка pytest
pip install pytest


2⃣ Пример теста
# test_sample.py

# A simple test to check if the sum function works correctly
def test_sum():
assert sum([1, 2, 3]) == 6, "Sum function did not return the expected result"


3⃣ Настройка GitHub Actions
Создайте файл .github/workflows/python-app.yml с содержимым:
name: Python application

# This triggers the workflow on every push or pull request to the main branch
on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x' # Specify the Python version you want to use

- name: Install dependencies
run: |
pip install pytest

- name: Run tests
run: |
pytest
Please open Telegram to view this post
VIEW IN TELEGRAM
👍21



tgoop.com/pyproglib/5899
Create:
Last Update:

⚙️ Как настроить автоматическое тестирование с pytest и GitHub Actions

Настроим автоматическое выполнение тестов каждый раз при обновлении кода.

1⃣ Установка pytest

pip install pytest


2⃣ Пример теста
# test_sample.py

# A simple test to check if the sum function works correctly
def test_sum():
assert sum([1, 2, 3]) == 6, "Sum function did not return the expected result"


3⃣ Настройка GitHub Actions
Создайте файл .github/workflows/python-app.yml с содержимым:
name: Python application

# This triggers the workflow on every push or pull request to the main branch
on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x' # Specify the Python version you want to use

- name: Install dependencies
run: |
pip install pytest

- name: Run tests
run: |
pytest

BY Библиотека питониста | Python, Django, Flask


Share with your friend now:
tgoop.com/pyproglib/5899

View MORE
Open in Telegram


Telegram News

Date: |

4How to customize a Telegram channel? But a Telegram statement also said: "Any requests related to political censorship or limiting human rights such as the rights to free speech or assembly are not and will not be considered." How to Create a Private or Public Channel on Telegram? Done! Now you’re the proud owner of a Telegram channel. The next step is to set up and customize your channel. Invite up to 200 users from your contacts to join your channel
from us


Telegram Библиотека питониста | Python, Django, Flask
FROM American