From c86a12c4223c6fd8de913647b0d9948f5c726f87 Mon Sep 17 00:00:00 2001 From: Cyrille Derche Date: Fri, 13 Sep 2024 20:27:44 +0200 Subject: [PATCH] fix tests --- .github/workflows/ci.yml | 2 +- .gitignore | 3 ++- app/test_main.py | 10 +++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffb67ce..c1a49d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} with: - coverageCommand: coverage run -m pytest + coverageCommand: coverage run -m pytest app build-push: name: Build + Push Image diff --git a/.gitignore b/.gitignore index f071240..e436ea9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ __pycache__ -.pytest_cache \ No newline at end of file +.pytest_cache +.coverage \ No newline at end of file diff --git a/app/test_main.py b/app/test_main.py index 6ef88ff..daed9d5 100644 --- a/app/test_main.py +++ b/app/test_main.py @@ -1,10 +1,10 @@ from fastapi.testclient import TestClient from main import app -client = TestClient(app) - def test_route(): - response = client.post("/test", json={"text": "Is this a test?"}) - assert response.status_code == 200 - assert response.json()["label"] == "QUESTION" + + with TestClient(app) as client: + response = client.post("/test", json={"text": "Is this a test?"}) + assert response.status_code == 200 + assert response.json()["label"] == "QUESTION"