~netlandish/django-wiki

c209d796c93970e5e863162e8ba293d03f384a13 — Benjamin Bach 8 years ago 78f2afd + e8a3945
Merge pull request #565 from duvholt/extensions-leak

Fix markdown extensions memory leak
3 files changed, 14 insertions(+), 2 deletions(-)

M tox.ini
M wiki/core/markdown/__init__.py
M wiki/tests/test_markdown.py
M tox.ini => tox.ini +2 -1
@@ 12,7 12,8 @@ deps =
     pytest
     Pillow==2.3.0
     django-classy-tags==0.4
     six==1.6.1
     six>=1.9
     mock>=2.0
     django_nyt==0.9.8
     django15: Django==1.5.12
     django16: Django==1.6.11

M wiki/core/markdown/__init__.py => wiki/core/markdown/__init__.py +1 -1
@@ 22,7 22,7 @@ class ArticleMarkdown(markdown.Markdown):

    def get_markdown_extensions(self):
        kwargs = settings.MARKDOWN_KWARGS
        extensions = kwargs.get('extensions', [])
        extensions = list(kwargs.get('extensions', []))
        extensions += self.core_extensions()
        extensions += plugin_registry.get_markdown_extensions()
        return extensions

M wiki/tests/test_markdown.py => wiki/tests/test_markdown.py +11 -0
@@ 2,7 2,18 @@ from __future__ import absolute_import, unicode_literals

from django.test import TestCase
import markdown
from wiki.core.markdown import ArticleMarkdown
from wiki.core.markdown.mdx.responsivetable import ResponsiveTableExtension
from mock import patch

class ArticleMarkdownTests(TestCase):
    @patch('wiki.core.markdown.settings')
    def test_do_not_modify_extensions(self, settings):
        extensions = ['footnotes', 'attr_list', 'sane_lists']
        settings.MARKDOWN_KWARGS = {'extensions': extensions}
        number_of_extensions = len(extensions)
        ArticleMarkdown(None)
        self.assertEqual(len(extensions), number_of_extensions)

class ResponsiveTableTests(TestCase):
    def setUp(self):