Skip to content
Permalink
Browse files

Why do we overcomplicate our tests so much?

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jul 31, 2016
1 parent 5f3bd6d commit 7ace85ec9e8cd9283f104aad3049cc96fbac3c0f
Showing with 10 additions and 13 deletions.
  1. +1 −0 tests/base.py
  2. +9 −13 tests/test_rst_compiler.py
@@ -141,6 +141,7 @@ def __init__(self, title, slug):
self._slug = slug
self._meta = {'slug': slug}
self.default_lang = 'en'
self._depfile = {}

def title(self):
return self._title
@@ -43,13 +43,12 @@
import pytest
import unittest

from nikola.post import Post
import nikola.plugins.compile.rest
from nikola.plugins.compile.rest import vimeo
import nikola.plugins.compile.rest.listing
from nikola.plugins.compile.rest.doc import Plugin as DocPlugin
from nikola.utils import _reload
from .base import BaseTestCase, FakeSite
from .base import BaseTestCase, FakeSite, FakePost


class ReSTExtensionTestCase(BaseTestCase):
@@ -72,23 +71,20 @@ def setHtmlFromRst(self, rst):
tmpdir = tempfile.mkdtemp()
inf = os.path.join(tmpdir, 'inf')
outf = os.path.join(tmpdir, 'outf')
depf = os.path.join(tmpdir, 'outf.dep')
with io.open(inf, 'w+', encoding='utf8') as f:
f.write(rst)
p = Post(inf, self.site.config, outf, False, None, '', self.compiler)
self.site.post_per_input_file[inf] = p
self.html = p.compile_html(inf, outf)
p = FakePost('', '')
p._depfile[outf] = []
self.compiler.site.post_per_input_file[inf] = p
self.html = self.compiler.compile_html(inf, outf)
with io.open(outf, 'r', encoding='utf8') as f:
self.html = f.read()
os.unlink(inf)
os.unlink(outf)
p.write_depfile(outf, p._depfile[outf])
if os.path.isfile(depf):
with io.open(depf, 'r', encoding='utf8') as f:
self.assertEqual(self.deps.strip(), f.read().strip())
os.unlink(depf)
else:
self.assertEqual(self.deps, None)
depfile = [p for p in p._depfile[outf] if p != outf]
depfile = '\n'.join(depfile)
if depfile:
self.assertEqual(self.deps.strip(), depfile)
os.rmdir(tmpdir)
self.html_doc = html.parse(StringIO(self.html))

0 comments on commit 7ace85e

Please sign in to comment.
You can’t perform that action at this time.