Skip to content

Instantly share code, notes, and snippets.

@jarshwah
Created February 14, 2020 05:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarshwah/09b03a4eec768ef82bcc3ebb9e4dfa05 to your computer and use it in GitHub Desktop.
Save jarshwah/09b03a4eec768ef82bcc3ebb9e4dfa05 to your computer and use it in GitHub Desktop.
def pytest_configure(config):
config.addinivalue_line(
"markers", "enable_inline_css: run css postprocessing over generated emails"
)
@pytest.fixture(autouse=True)
def disable_inline_css(request, monkeypatch):
if "enable_inline_css" in request.keywords:
return
monkeypatch.setattr("email_templates.models.inline_css", identity)
@pytest.fixture(autouse=True)
def enable_db_access_for_all_tests(db):
pass
import unittest
import pytest
class EmailTests(unittest.TestCase):
# disable the global mock!
@pytest.mark.enable_inline_css
def test_some_email_css(self):
self.assertIn("<div style='...'>email</div>", generate_email())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment