From 6fa3a9a630b2a15096101531884c5e55e90dd189 Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Mon, 18 May 2026 09:30:38 -0400 Subject: [PATCH 1/2] Remove codecs from tests --- tests/unit_test.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/tests/unit_test.py b/tests/unit_test.py index e56c203..eef614d 100644 --- a/tests/unit_test.py +++ b/tests/unit_test.py @@ -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 @@ -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", "utf-8") as f: content = f.read().strip() self.assertEqual(post.metadata, {}) @@ -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", "utf-8") as f: data = f.read() post = frontmatter.load("tests/yaml/unpretty.md") @@ -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", "utf-8") as f: format = frontmatter.detect_format(f.read(), frontmatter.handlers) self.assertIsInstance(format, Handler) @@ -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): From c4fdd50f3f8785f8f794e8f9ca5d1833824cb9eb Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Mon, 18 May 2026 09:36:21 -0400 Subject: [PATCH 2/2] Encoding is a kwarg --- tests/unit_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit_test.py b/tests/unit_test.py index eef614d..188fb4c 100644 --- a/tests/unit_test.py +++ b/tests/unit_test.py @@ -64,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 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, {}) @@ -110,7 +110,7 @@ def test_to_string(self): def test_pretty_dumping(self): "Use pyaml to dump nicer" if pyaml is not None: - with 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") @@ -177,7 +177,7 @@ def test_detect_format(self): "detect format based on default handlers" for filename, Handler in self.TEST_FILES.items(): - with 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)