new core.runner helper to avoid local caching issues w. coverage tests; .settings, apps.dash.tests.ITs.test_wallet_views updated accordingly
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Disco DeDisco
2026-03-12 14:23:09 -04:00
parent 068b99d030
commit 69fea65bf9
3 changed files with 24 additions and 6 deletions

View File

@@ -1,12 +1,11 @@
import lxml.html
from django.test import override_settings, TestCase
from django.test import TestCase
from apps.applets.models import Applet, UserApplet
from apps.lyric.models import Token, User, Wallet
@override_settings(COMPRESS_ENABLED=False)
class WalletViewTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="capman@test.io")
@@ -49,7 +48,6 @@ class WalletViewTest(TestCase):
self.assertGreater(len(bundles), 0)
@override_settings(COMPRESS_ENABLED=False)
class WalletViewAppletContextTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="walletctx@test.io")
@@ -85,7 +83,6 @@ class WalletViewAppletContextTest(TestCase):
[_] = parsed.cssselect(".gear-btn")
@override_settings(COMPRESS_ENABLED=False)
class ToggleWalletAppletsTest(TestCase):
def setUp(self):
self.user = User.objects.create(email="wallettoggle@test.io")

15
src/core/runner.py Normal file
View File

@@ -0,0 +1,15 @@
import time
from django.test.runner import DiscoverRunner
class RobustCompressorTestRunner(DiscoverRunner):
def setup_test_environment(self, **kwargs):
super().setup_test_environment(**kwargs)
from compressor.storage import CompressorFileStorage
_orig_save = CompressorFileStorage.save
def _robust_save(self, name, content):
for _ in range(5):
try: return _orig_save(self, name, content)
except PermissionError: time.sleep(0.05)
raise
CompressorFileStorage.save = _robust_save

View File

@@ -14,8 +14,6 @@ from pathlib import Path
import dj_database_url
import os
import sys
if 'test' in sys.argv:
COMPRESS_ENABLED = False
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -206,3 +204,11 @@ MAILGUN_DOMAIN = "howdy.earthmanrpg.com" # Your Mailgun domain
# Stripe payment settings
STRIPE_PUBLISHABLE_KEY = os.environ.get("STRIPE_PUBLISHABLE_KEY", "")
STRIPE_SECRET_KEY = os.environ.get("STRIPE_SECRET_KEY", "")
if 'test' in sys.argv:
import shutil
_cache_dir = BASE_DIR / 'static' / 'CACHE'
if _cache_dir.exists():
shutil.rmtree(_cache_dir, ignore_errors=True)
COMPRESS_CACHE_BACKEND = 'default'
TEST_RUNNER = 'core.runner.RobustCompressorTestRunner'