From 600f92a7fae829998ddabe416e7c00371038e75a Mon Sep 17 00:00:00 2001 From: Steven Eardley Date: Mon, 7 Oct 2024 19:27:57 +0100 Subject: [PATCH] Prevent some leaky test scenarios --- doajtest/unit/api_tests/test_api_account.py | 19 ++++++++++--------- doajtest/unit/test_prune_marvel.py | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/doajtest/unit/api_tests/test_api_account.py b/doajtest/unit/api_tests/test_api_account.py index 0ea640259f..0a2826499c 100644 --- a/doajtest/unit/api_tests/test_api_account.py +++ b/doajtest/unit/api_tests/test_api_account.py @@ -16,15 +16,16 @@ def setUpClass(cls): # Turn off debug so we're allowed to add these routes after the app has been used in other tests cls.app_test.debug = False - @cls.app_test.route('/hello') - @api_key_required - def hello_world(): - return Response("hello, world!") - - @cls.app_test.route('/helloopt') - @api_key_optional - def hello_world_opt(): - return Response("hello, world!") + with cls.app_test.app_context(): + @cls.app_test.route('/hello') + @api_key_required + def hello_world(): + return Response("hello, world!") + + @cls.app_test.route('/helloopt') + @api_key_optional + def hello_world_opt(): + return Response("hello, world!") # Reinstate debug cls.app_test.debug = True diff --git a/doajtest/unit/test_prune_marvel.py b/doajtest/unit/test_prune_marvel.py index a78cc193b9..56ab07f754 100644 --- a/doajtest/unit/test_prune_marvel.py +++ b/doajtest/unit/test_prune_marvel.py @@ -1,13 +1,13 @@ import datetime, calendar from dateutil.relativedelta import relativedelta from freezegun import freeze_time +from unittest import TestCase -from doajtest.helpers import DoajTestCase from portality.lib.dates import FMT_DATE_YMDOT from portality.scripts.prune_marvel import generate_delete_pattern -class TestPruneMarvel(DoajTestCase): +class TestPruneMarvel(TestCase): @classmethod def setUpClass(cls):