From a974fd6e902ccc9e5b782707344d9af734b169b6 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Fri, 14 Dec 2012 12:09:11 -0500 Subject: Normalize line endings in tests as git may alter them on Windows. Without this, all SyntaxTests would fail from a git checkout on Windows. On other systems, it should have no effect. --- tests/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/__init__.py') diff --git a/tests/__init__.py b/tests/__init__.py index c790b09..4722e33 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -90,10 +90,11 @@ class CheckSyntax(object): input = f.read() output_file = file + config.get(cfg_section, 'output_ext') with codecs.open(output_file, encoding="utf-8") as f: - expected_output = f.read() + # Normalize line endings (on windows, git may have altered line endings). + expected_output = f.read().replace("\r\n", "\n") output = markdown.markdown(input, **get_args(file, config)) if tidy and config.get(cfg_section, 'normalize'): - # Normalize whitespace before comparing. + # Normalize whitespace with Tidy before comparing. expected_output = normalize(expected_output) output = normalize(output) elif config.get(cfg_section, 'normalize'): -- cgit v1.2.3 From 9bcd7b8763627c64184b0bf147ec1830fde0a5dc Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Fri, 14 Dec 2012 13:31:41 -0500 Subject: Testing framework now runs on Python 2 & 3 unmodified. --- tests/__init__.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tests/__init__.py') diff --git a/tests/__init__.py b/tests/__init__.py index 4722e33..bb56bd4 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,4 +1,4 @@ -from __future__ import with_statement + import os import markdown import codecs @@ -6,11 +6,11 @@ import difflib try: import nose except ImportError: - raise ImportError, "The nose testing framework is required to run " \ + raise ImportError("The nose testing framework is required to run " \ "Python-Markdown tests. Run `easy_install nose` " \ - "to install the latest version." -import util -from plugins import HtmlOutput, Markdown + "to install the latest version.") +from . import util +from .plugins import HtmlOutput, Markdown try: import tidy except ImportError: @@ -84,7 +84,7 @@ class CheckSyntax(object): """ Compare expected output to actual output and report result. """ cfg_section = get_section(file, config) if config.get(cfg_section, 'skip'): - raise nose.plugins.skip.SkipTest, 'Test skipped per config.' + raise nose.plugins.skip.SkipTest('Test skipped per config.') input_file = file + config.get(cfg_section, 'input_ext') with codecs.open(input_file, encoding="utf-8") as f: input = f.read() @@ -99,7 +99,7 @@ class CheckSyntax(object): output = normalize(output) elif config.get(cfg_section, 'normalize'): # Tidy is not available. Skip this test. - raise nose.plugins.skip.SkipTest, 'Test skipped. Tidy not available in system.' + raise nose.plugins.skip.SkipTest('Test skipped. Tidy not available in system.') diff = [l for l in difflib.unified_diff(expected_output.splitlines(True), output.splitlines(True), output_file, @@ -125,17 +125,17 @@ def generate(file, config): """ Write expected output file for given input. """ cfg_section = get_section(file, config) if config.get(cfg_section, 'skip'): - print 'Skipping:', file + print('Skipping:', file) return None input_file = file + config.get(cfg_section, 'input_ext') output_file = file + config.get(cfg_section, 'output_ext') if not os.path.isfile(output_file) or \ os.path.getmtime(output_file) < os.path.getmtime(input_file): - print 'Generating:', file + print('Generating:', file) markdown.markdownFromFile(input=input_file, output=output_file, encoding='utf-8', **get_args(file, config)) else: - print 'Already up-to-date:', file + print('Already up-to-date:', file) def generate_all(): """ Generate expected output for all outdated tests. """ -- cgit v1.2.3