aboutsummaryrefslogtreecommitdiffstats
path: root/tests/base.py
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2009-05-30 22:31:55 -0400
committerWaylan Limberg <waylan@gmail.com>2009-06-05 22:25:51 -0400
commit8b430d251b2518fa3303d7027f50268e0254b7a1 (patch)
treec9265f6ce7024d400b6c8bb58c26bda6a97f86d5 /tests/base.py
parentcc452998dc1af441cf3f9c5d0c7287cb5de48c4a (diff)
downloadmarkdown-8b430d251b2518fa3303d7027f50268e0254b7a1.tar.gz
markdown-8b430d251b2518fa3303d7027f50268e0254b7a1.tar.bz2
markdown-8b430d251b2518fa3303d7027f50268e0254b7a1.zip
Moves tests to a subdir of the markdown lib.
Diffstat (limited to 'tests/base.py')
-rw-r--r--tests/base.py62
1 files changed, 0 insertions, 62 deletions
diff --git a/tests/base.py b/tests/base.py
deleted file mode 100644
index 9e70996..0000000
--- a/tests/base.py
+++ /dev/null
@@ -1,62 +0,0 @@
-import os, codecs
-import markdown
-from nose.tools import assert_equal
-import difflib
-from plugins import MdSyntaxError
-
-class SyntaxBase:
- """
- Generator that steps through all files in a dir and runs each text file
- (*.txt) as a seperate unit test.
-
- Each subclass of SyntaxBase should define `dir` as a string containing the
- name of the directory which holds the test files. For example:
-
- dir = "path/to/mytests"
-
- A subclass may redefine the `setUp` method to create a custom `Markdown`
- instance specific to that batch of tests.
-
- """
-
- dir = ""
-
- def __init__(self):
- self.files = [x.replace(".txt", "")
- for x in os.listdir(self.dir) if x.endswith(".txt")]
-
- def setUp(self):
- """
- Create Markdown instance.
-
- Override this method to create a custom `Markdown` instance assigned to
- `self.md`. For example:
-
- self.md = markdown.Markdown(extensions=["footnotes"], safe_mode="replace")
-
- """
- self.md = markdown.Markdown()
-
- def tearDown(self):
- """ tearDown is not implemented. """
- pass
-
- def test_syntax(self):
- for file in self.files:
- yield self.check_syntax, file
-
- def check_syntax(self, file):
- input_file = os.path.join(self.dir, file + ".txt")
- input = codecs.open(input_file, encoding="utf-8").read()
- output_file = os.path.join(self.dir, file + ".html")
- expected_output = codecs.open(output_file, encoding="utf-8").read()
- output = self.normalize(self.md.convert(input))
- diff = [l for l in difflib.unified_diff(self.normalize(expected_output),
- output, output_file,
- 'actual_output.html', n=3)]
- if diff:
- #assert False,
- raise MdSyntaxError('Output from "%s" failed to match expected output.\n\n%s' % (input_file, ''.join(diff)))
-
- def normalize(self, text):
- return ['%s\n' % l for l in text.strip().split('\n')]