Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing PEP8 complaints in tests #2185

Merged
merged 1 commit into from Dec 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/document_path_handlers.py
Expand Up @@ -18,5 +18,5 @@
for k in sorted(n.path_handlers.keys()):
v = n.path_handlers[k]
print(k)
print('\n'.join(' '+l.strip() for l in v.__doc__.splitlines()))
print('\n'.join(' ' + l.strip() for l in v.__doc__.splitlines()))
print()
1 change: 1 addition & 0 deletions tests/conftest.py
@@ -1,6 +1,7 @@
import os
import pytest


@pytest.yield_fixture(autouse=True)
def ensure_chdir():
x = os.getcwd()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_command_import_wordpress.py
Expand Up @@ -257,7 +257,7 @@ def test_importing_posts_and_attachments(self):
'content': 'Das Cover von Arzt+Pfusch - S.I.C.K.',
'files': ['/wp-content/uploads/2008/07/arzt_und_pfusch-sick-cover.png',
'/wp-content/uploads/2008/07/arzt_und_pfusch-sick-cover-150x150.png'],
'title': 'Arzt+Pfusch - S.I.C.K.'}})
'title': 'Arzt+Pfusch - S.I.C.K.'}})

write_content.assert_any_call(
'new_site/posts/2008/07/arzt-und-pfusch-s-i-c-k.md'.replace('/', os.sep),
Expand Down
4 changes: 4 additions & 0 deletions tests/test_integration.py
Expand Up @@ -313,6 +313,7 @@ def test_check_files(self):
with cd(self.target_dir):
self.assertIsNone(__main__.main(['check', '-f']))


class TestCheckAbsoluteSubFolder(TestCheck):
"""Validate links in a site which is:

Expand Down Expand Up @@ -526,6 +527,7 @@ def fill_site(self):
dst1 = os.path.join(self.target_dir, 'posts', '1.rst')
shutil.copy(src1, dst1)
os.system('rm "{0}/stories/creating-a-theme.rst" "{0}/stories/extending.txt" "{0}/stories/internals.txt" "{0}/stories/manual.rst" "{0}/stories/social_buttons.txt" "{0}/stories/theming.rst" "{0}/stories/path_handlers.txt" "{0}/stories/charts.txt"'.format(self.target_dir))

def test_invariance(self):
"""Compare the output to the canonical output."""
if sys.version_info[0:2] != (2, 7):
Expand Down Expand Up @@ -560,6 +562,7 @@ def fill_site(self):
with io.open(target_path, "w+", encoding="utf8") as outf:
outf.write("foo")


class RedirectionsTest2(TestCheck):
"""Check external REDIRECTIONS"""

Expand All @@ -570,6 +573,7 @@ def patch_site(self):
with io.open(conf_path, "a", encoding="utf8") as outf:
outf.write("""\n\nREDIRECTIONS = [ ("foo.html", "http://www.example.com/"), ]\n\n""")


class RedirectionsTest3(TestCheck):
"""Check relative REDIRECTIONS"""

Expand Down
15 changes: 8 additions & 7 deletions tests/test_rss_feeds.py
Expand Up @@ -50,13 +50,14 @@ def setUp(self):
with mock.patch('nikola.post.get_meta',
mock.Mock(return_value=(
({'title': 'post title',
'slug': 'awesome_article',
'date': '2012-10-01 22:41',
'author': None,
'tags': 'tags',
'link': 'link',
'description': 'description',
'enclosure': 'http://www.example.org/foo.mp3'}, True)
'slug': 'awesome_article',
'date': '2012-10-01 22:41',
'author': None,
'tags': 'tags',
'link': 'link',
'description': 'description',
'enclosure': 'http://www.example.org/foo.mp3'},
True)
))):
with mock.patch('nikola.nikola.utils.os.path.isdir',
mock.Mock(return_value=True)):
Expand Down
16 changes: 6 additions & 10 deletions tests/test_utils.py
@@ -1,10 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import os
import sys


import unittest
import mock
import lxml.html
Expand Down Expand Up @@ -323,13 +318,14 @@ def test_get_metadata_from_file():
from nikola.post import _get_metadata_from_file
g = _get_metadata_from_file
assert list(g([]).values()) == []
assert str(g(["======","FooBar","======"])["title"]) == 'FooBar'
assert str(g(["FooBar","======"])["title"]) == 'FooBar'
assert str(g(["======", "FooBar", "======"])["title"]) == 'FooBar'
assert str(g(["FooBar", "======"])["title"]) == 'FooBar'
assert str(g(["#FooBar"])["title"]) == 'FooBar'
assert str(g([".. title: FooBar"])["title"]) == 'FooBar'
assert 'title' not in g(["","",".. title: FooBar"])
assert 'title' in g(["",".. title: FooBar"])
assert 'title' in g([".. foo: bar","","FooBar", "------"])
assert 'title' not in g(["", "", ".. title: FooBar"])
assert 'title' in g(["", ".. title: FooBar"])
assert 'title' in g([".. foo: bar", "", "FooBar", "------"])


if __name__ == '__main__':
unittest.main()