diff --git a/runtests.py b/runtests.py deleted file mode 100644 index 409268a..0000000 --- a/runtests.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python -from nose.core import run, collector - -if __name__ == '__main__': - run() diff --git a/setup.py b/setup.py index 22e3edd..6714b8d 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,7 @@ import codecs import os from setuptools import setup, find_packages +from setuptools.command.test import test as TestCommand read = lambda filepath: codecs.open(filepath, 'r', 'utf-8').read() @@ -12,6 +13,18 @@ execfile(os.path.join(os.path.dirname(__file__), 'markdownify', 'pkgmeta.py'), pkgmeta) +class PyTest(TestCommand): + def finalize_options(self): + TestCommand.finalize_options(self) + self.test_args = ['tests', '-s'] + self.test_suite = True + + def run_tests(self): + import pytest + errno = pytest.main(self.test_args) + raise SystemExit(errno) + + setup( name='markdownify', description='Convert HTML to markdown.', @@ -25,8 +38,7 @@ setup( zip_safe=False, include_package_data=True, tests_require=[ - 'nose', - 'unittest2', + 'pytest', ], install_requires=[ 'lxml', @@ -44,5 +56,7 @@ setup( 'Topic :: Utilities' ], setup_requires=[], - test_suite='runtests.collector', + cmdclass={ + 'test': PyTest, + }, ) diff --git a/tests.py b/tests.py deleted file mode 100644 index 57c2277..0000000 --- a/tests.py +++ /dev/null @@ -1,123 +0,0 @@ -import unittest -from markdownify import markdownify as md - - -class BasicTests(unittest.TestCase): - - def test_single_tag(self): - self.assertEqual(md('Hello'), 'Hello') - - def test_soup(self): - self.assertEqual(md('
Hello').strip(), '> Hello') - - def test_nested_blockquote(self): - self.assertEqual( - md('
And she was like').strip(), - '> And she was like \n> > Hello' - ) - - def test_br(self): - self.assertEqual(md('aHello
hello
'), 'hello\n\n') - - def test_strong(self): - self.assertEqual(md('Hello'), '**Hello**') - - def test_ul(self): - self.assertEqual(md('This is an example link.
'), - 'This is an [example link](http://example.com/).\n\n' - ) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_advanced.py b/tests/test_advanced.py new file mode 100644 index 0000000..4c480d7 --- /dev/null +++ b/tests/test_advanced.py @@ -0,0 +1,6 @@ +from markdownify import markdownify as md + + +def test_nested(): + text = md('This is an example link.
') + assert text == 'This is an [example link](http://example.com/).\n\n' diff --git a/tests/test_args.py b/tests/test_args.py new file mode 100644 index 0000000..ebce4a8 --- /dev/null +++ b/tests/test_args.py @@ -0,0 +1,25 @@ +""" +Test whitelisting/blacklisting of specific tags. + +""" +from markdownify import markdownify as md + + +def test_strip(): + text = md('Some Text', strip=['a']) + assert text == 'Some Text' + + +def test_do_not_strip(): + text = md('Some Text', strip=[]) + assert text == '[Some Text](https://github.com/matthewwithanm)' + + +def test_convert(): + text = md('Some Text', convert=['a']) + assert text == '[Some Text](https://github.com/matthewwithanm)' + + +def test_do_not_convert(): + text = md('Some Text', convert=[]) + assert text == 'Some Text' diff --git a/tests/test_basic.py b/tests/test_basic.py new file mode 100644 index 0000000..78775b6 --- /dev/null +++ b/tests/test_basic.py @@ -0,0 +1,13 @@ +from markdownify import markdownify as md + + +def test_single_tag(): + assert md('Hello') == 'Hello' + + +def test_soup(): + assert md('Hello').strip() == '> Hello' + + +def test_nested_blockquote(): + text = md('
And she was like').strip() + assert text == '> And she was like \n> > Hello' + + +def test_br(): + assert md('aHello
hello
') == 'hello\n\n' + + +def test_strong(): + assert md('Hello') == '**Hello**' + + +def test_ul(): + assert md('