Skip to content

Commit d557a77

Browse files
committedOct 9, 2018
Add a simple test
1 parent 24f8bcd commit d557a77

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed
 

‎README.rst

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ Use it.
2525
>>> HTMLSlacker('<b>Hello</b>, <i>Slack</i>!').get_output()
2626
'*Hello*, _Slack_!'
2727
28+
Test it.
29+
30+
.. code:: python
31+
32+
$ python setup.py test
33+
34+
2835
Requirements
2936
------------
3037

‎setup.cfg

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[metadata]
22
description-file = README.rst
3+
4+
[aliases]
5+
test=pytest

‎setup.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import sys
12
from setuptools import setup, find_packages
23
from os.path import join, dirname
34

5+
needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
6+
pytest_runner = ['pytest-runner'] if needs_pytest else []
7+
48
setup(
59
name='html-slacker',
610
packages=find_packages(),
@@ -19,5 +23,7 @@
1923
'Topic :: Software Development :: Libraries',
2024
'Environment :: Console',
2125
],
26+
setup_requires=pytest_runner,
27+
tests_require=["pytest"],
2228
python_requires='>=2.5'
2329
)

‎test_general.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from htmlslacker import HTMLSlacker
2+
3+
4+
def test_example_1():
5+
html = """
6+
<b>Hello</b><br>
7+
There is <i>something</i> interesting about <code>this doc</code>
8+
9+
<p>
10+
And <a href="http://example.com/">here is a
11+
link in a paragraph!</a>
12+
</p>
13+
"""
14+
expected = "*Hello*\n There is _something_ interesting about `this doc` \n And <http://example.com/|here is a link in a paragraph!>"
15+
output = HTMLSlacker(html).get_output()
16+
assert(output == expected)

0 commit comments

Comments
 (0)
Please sign in to comment.