Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions tests/unit_test.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import codecs
import doctest
import glob
import json
import os
import shutil
import sys
import tempfile
import textwrap
import unittest
Expand Down Expand Up @@ -70,7 +64,7 @@ def test_check_empty_frontmatter(self):
def test_no_frontmatter(self):
"This is not a zen exercise."
post = frontmatter.load("tests/empty/no-frontmatter.txt")
with codecs.open("tests/empty/no-frontmatter.txt", "r", "utf-8") as f:
with open("tests/empty/no-frontmatter.txt", "r", encoding="utf-8") as f:
content = f.read().strip()

self.assertEqual(post.metadata, {})
Expand Down Expand Up @@ -116,7 +110,7 @@ def test_to_string(self):
def test_pretty_dumping(self):
"Use pyaml to dump nicer"
if pyaml is not None:
with codecs.open("tests/yaml/unpretty.md", "r", "utf-8") as f:
with open("tests/yaml/unpretty.md", "r", encoding="utf-8") as f:
data = f.read()

post = frontmatter.load("tests/yaml/unpretty.md")
Expand Down Expand Up @@ -183,7 +177,7 @@ def test_detect_format(self):
"detect format based on default handlers"

for filename, Handler in self.TEST_FILES.items():
with codecs.open(filename, "r", "utf-8") as f:
with open(filename, "r", encoding="utf-8") as f:
format = frontmatter.detect_format(f.read(), frontmatter.handlers)
self.assertIsInstance(format, Handler)

Expand All @@ -207,14 +201,12 @@ def test_custom_handler(self):

# not including this in the regular test directory
# because it would/should be invalid per the defaults
custom = textwrap.dedent(
"""
custom = textwrap.dedent("""
...
dummy frontmatter
...
dummy content
"""
)
""")

# and a custom handler that really doesn't do anything
class DummyHandler(object):
Expand Down