From f087887ab9d18d55c686da366fa3a23b303272a0 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Thu, 12 Jul 2012 09:56:42 -0400 Subject: Fixed #115. Make sure all file objects are closed. --- tests/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests/__init__.py') diff --git a/tests/__init__.py b/tests/__init__.py index 26cc0d0..c790b09 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,3 +1,4 @@ +from __future__ import with_statement import os import markdown import codecs @@ -85,9 +86,11 @@ class CheckSyntax(object): if config.get(cfg_section, 'skip'): raise nose.plugins.skip.SkipTest, 'Test skipped per config.' input_file = file + config.get(cfg_section, 'input_ext') - input = codecs.open(input_file, encoding="utf-8").read() + with codecs.open(input_file, encoding="utf-8") as f: + input = f.read() output_file = file + config.get(cfg_section, 'output_ext') - expected_output = codecs.open(output_file, encoding="utf-8").read() + with codecs.open(output_file, encoding="utf-8") as f: + expected_output = f.read() output = markdown.markdown(input, **get_args(file, config)) if tidy and config.get(cfg_section, 'normalize'): # Normalize whitespace before comparing. -- cgit v1.2.3