2
0
Fork 0

test: skip some tests if mako not installed

also change corresponding tox env to 'nox' to reflect its "bare-bones"
nature and not just a lack of 'db'
This commit is contained in:
Lance Edgar 2024-08-26 14:34:35 -05:00
parent 2b1c958aa7
commit 7ee8398718
3 changed files with 21 additions and 4 deletions

View file

@ -3,6 +3,8 @@
from unittest import TestCase from unittest import TestCase
from unittest.mock import patch, MagicMock from unittest.mock import patch, MagicMock
import pytest
from wuttjamaican.email import handler as mod from wuttjamaican.email import handler as mod
from wuttjamaican.email import Message from wuttjamaican.email import Message
from wuttjamaican.conf import WuttaConfig from wuttjamaican.conf import WuttaConfig
@ -13,6 +15,11 @@ from wuttjamaican.exc import ConfigurationError
class TestEmailHandler(TestCase): class TestEmailHandler(TestCase):
def setUp(self): def setUp(self):
try:
import mako
except ImportError:
pytest.skip("test not relevant without mako")
self.config = WuttaConfig() self.config = WuttaConfig()
self.app = self.config.get_app() self.app = self.config.get_app()

View file

@ -398,6 +398,11 @@ class TestAppHandler(FileConfigTestCase):
self.assertIsInstance(auth, AuthHandler) self.assertIsInstance(auth, AuthHandler)
def test_get_email_handler(self): def test_get_email_handler(self):
try:
import mako
except ImportError:
pytest.skip("test not relevant without mako")
from wuttjamaican.email import EmailHandler from wuttjamaican.email import EmailHandler
mail = self.app.get_email_handler() mail = self.app.get_email_handler()
@ -409,7 +414,12 @@ class TestAppHandler(FileConfigTestCase):
people = self.app.get_people_handler() people = self.app.get_people_handler()
self.assertIsInstance(people, PeopleHandler) self.assertIsInstance(people, PeopleHandler)
def test_get_send_email(self): def test_send_email(self):
try:
import mako
except ImportError:
pytest.skip("test not relevant without mako")
from wuttjamaican.email import EmailHandler from wuttjamaican.email import EmailHandler
with patch.object(EmailHandler, 'send_email') as send_email: with patch.object(EmailHandler, 'send_email') as send_email:

View file

@ -1,12 +1,12 @@
[tox] [tox]
envlist = py38, py39, py310, py311, nodb envlist = py38, py39, py310, py311, nox
[testenv] [testenv]
extras = db,docs,tests extras = db,email,docs,tests
commands = pytest {posargs} commands = pytest {posargs}
[testenv:nodb] [testenv:nox]
extras = tests extras = tests
[testenv:coverage] [testenv:coverage]