From dc7aedfe825b02bd2cb526c0aba9c421822a37d1 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Fri, 21 Dec 2012 16:19:30 -0500 Subject: tox now installs tests as a module. Still not running sytax tests. Package_data (in setup-tests.py) doesn't recursively search subdirs - need to do so manually. --- setup-tests.py | 18 ++++++++++++++++++ tests/test_syntax.py | 30 ++++++++++++++++++++++++++---- tests/util.py | 23 ----------------------- tox.ini | 6 ++++-- 4 files changed, 48 insertions(+), 29 deletions(-) create mode 100644 setup-tests.py delete mode 100644 tests/util.py diff --git a/setup-tests.py b/setup-tests.py new file mode 100644 index 0000000..c5d1acd --- /dev/null +++ b/setup-tests.py @@ -0,0 +1,18 @@ +from distutils.core import setup +import os + +setup_path = os.path.dirname(__file__) + +setup( + name='tests', + version='1.0', + description='Python-Markdown testing Framework', + author='Waylan Limberg', + author_email='waylan@gmail.com', + packages=['tests'], + package_dir={'tests': os.path.join(setup_path, 'tests')}, + package_data={'tests': [os.path.join(setup_path, 'tests/*.txt'), + os.path.join(setup_path,'tests/*.html'), + os.path.join(setup_path, 'tests/*.cfg')]}, + scripts=[os.path.join(setup_path, 'run-tests.py')], +) \ No newline at end of file diff --git a/tests/test_syntax.py b/tests/test_syntax.py index ab7299d..1af9a46 100644 --- a/tests/test_syntax.py +++ b/tests/test_syntax.py @@ -4,8 +4,30 @@ import markdown import codecs import difflib import nose -from . import util -from .plugins import HtmlOutput, Markdown + +import sys +if sys.version_info[0] == 3: + from configparser import SafeConfigParser +else: + from ConfigParser import SafeConfigParser + +class MarkdownSyntaxError(Exception): + pass + + +class CustomConfigParser(SafeConfigParser): + def get(self, section, option): + value = SafeConfigParser.get(self, section, option) + if option == 'extensions': + if len(value.strip()): + return value.split(',') + else: + return [] + if value.lower() in ['yes', 'true', 'on', '1']: + return True + if value.lower() in ['no', 'false', 'off', '0']: + return False + return value try: import tidy except ImportError: @@ -29,7 +51,7 @@ def relpath(path, start=test_dir): def get_config(dir_name): """ Get config for given directory name. """ - config = util.CustomConfigParser({'normalize': '0', + config = CustomConfigParser({'normalize': '0', 'skip': '0', 'input_ext': '.txt', 'output_ext': '.html'}) @@ -101,7 +123,7 @@ class CheckSyntax(object): 'actual_output.html', n=3)] if diff: - raise util.MarkdownSyntaxError('Output from "%s" failed to match expected ' + raise MarkdownSyntaxError('Output from "%s" failed to match expected ' 'output.\n\n%s' % (input_file, ''.join(diff))) def TestSyntax(): diff --git a/tests/util.py b/tests/util.py deleted file mode 100644 index bbf7aea..0000000 --- a/tests/util.py +++ /dev/null @@ -1,23 +0,0 @@ -import sys -if sys.version_info[0] == 3: - from configparser import SafeConfigParser -else: - from ConfigParser import SafeConfigParser - -class MarkdownSyntaxError(Exception): - pass - - -class CustomConfigParser(SafeConfigParser): - def get(self, section, option): - value = SafeConfigParser.get(self, section, option) - if option == 'extensions': - if len(value.strip()): - return value.split(',') - else: - return [] - if value.lower() in ['yes', 'true', 'on', '1']: - return True - if value.lower() in ['no', 'false', 'off', '0']: - return False - return value diff --git a/tox.ini b/tox.ini index a3ee9fd..7230b01 100644 --- a/tox.ini +++ b/tox.ini @@ -3,5 +3,7 @@ envlist = py27,py32 [testenv] deps=nose -commands = {envpython} {toxinidir}/run-tests.py {posargs} -#commands= nosetests \ No newline at end of file +changedir = {toxworkdir}/{envname} +commands = {envpython} {toxinidir}/setup-tests.py --quiet install + {envpython} {envbindir}/run-tests.py {posargs} {toxworkdir}/{envname}/Lib/site-packages/tests +# for tox v1.4.3 replace `{toxworkdir}/{envname}/Lib/site-packages/tests` with `{envsitepackagesdir}/tests` \ No newline at end of file -- cgit v1.2.1