Fix the hardcoded path

This commit is contained in:
Jannes van den Bogert 2024-06-26 14:44:52 +02:00
parent 3c984992b9
commit d50118bfcb
2 changed files with 3 additions and 8 deletions

View file

@ -2,8 +2,6 @@ import pytest
from flask import Flask, json from flask import Flask, json
from werkzeug.exceptions import HTTPException, NotFound, InternalServerError from werkzeug.exceptions import HTTPException, NotFound, InternalServerError
from unittest.mock import patch from unittest.mock import patch
# Import the module where branch_coverage and track_coverage are defined
from flask import branch_coverage, track_coverage from flask import branch_coverage, track_coverage
def create_app(): def create_app():
@ -54,11 +52,8 @@ def test_not_found_handling(client):
def test_no_route(client): def test_no_route(client):
response = client.get('/no_route') response = client.get('/no_route')
assert response.status_code == 404 assert response.status_code == 404
# Revised or removed based on actual coverage tracking setup
# assert branch_coverage.get('dispatch_request_no_route_found', False)
# Test to save branch coverage data into a JSON file after all tests
def test_save_branch_coverage(): def save_coverage_to_json(file_path='coverage_result.json'):
file_path = '/Users/jannesvandenbogert/Documents/GitHub/flask/coverage_result.json'
with open(file_path, 'w') as json_file: with open(file_path, 'w') as json_file:
json.dump(branch_coverage, json_file, indent=4) json.dump(branch_coverage, json_file, indent=4)

View file

@ -6,7 +6,7 @@ from flask.app import Flask as FlaskApp
from flask import branch_coverage, track_coverage from flask import branch_coverage, track_coverage
import json import json
def save_coverage_to_json(file_path='/Users/jannesvandenbogert/Documents/GitHub/flask/coverage_result.json'): def save_coverage_to_json(file_path='coverage_result.json'):
with open(file_path, 'w') as json_file: with open(file_path, 'w') as json_file:
json.dump(branch_coverage, json_file, indent=4) json.dump(branch_coverage, json_file, indent=4)