Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 7ace85e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions tests/base.py
Expand Up @@ -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
Expand Down
22 changes: 9 additions & 13 deletions tests/test_rst_compiler.py
Expand Up @@ -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):
Expand All @@ -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))

Expand Down

0 comments on commit 7ace85e

Please sign in to comment.