Skip to content

Commit 819fabb

Browse files
committed
Merge branch 'release/4.0.2'
2 parents 23e7746 + 03ba820 commit 819fabb

9 files changed

Lines changed: 53 additions & 31 deletions

File tree

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ python:
88
- "3.6"
99
- "3.7"
1010
- "3.8"
11+
- "3.9"
1112
# PyPy versions
1213
- "pypy3"
1314
# command to install dependencies
1415
install:
1516
- imagesize=''
16-
- pip install -U coveralls pytest pytest-cov coverage codecov
17+
- pip install -U pytest pytest-cov coverage codecov
1718
- if [[ $IMAGESIZE == true ]] ; then imagesize='[imagesize]' ; fi
1819
- pip install -e ".${imagesize}"
1920
# command to run tests
2021
script: py.test
2122
after_success:
22-
- coveralls
2323
- codecov

README.textile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
!https://travis-ci.org/textile/python-textile.svg!:https://travis-ci.org/textile/python-textile !https://coveralls.io/repos/github/textile/python-textile/badge.svg!:https://coveralls.io/github/textile/python-textile?branch=master !https://codecov.io/github/textile/python-textile/coverage.svg!:https://codecov.io/github/textile/python-textile !https://img.shields.io/pypi/pyversions/textile! !https://img.shields.io/pypi/wheel/textile!
1+
!https://travis-ci.org/textile/python-textile.svg!:https://travis-ci.org/textile/python-textile !https://codecov.io/github/textile/python-textile/coverage.svg!:https://codecov.io/github/textile/python-textile !https://img.shields.io/pypi/pyversions/textile! !https://img.shields.io/pypi/wheel/textile!
22

33
h1. python-textile
44

@@ -43,3 +43,15 @@ bc.. import textile
4343
h3. Notes:
4444

4545
* Active development supports Python 3.5 or later.
46+
47+
h3. Running Tests
48+
49+
To run the test suite, use pytest. `pytest-cov` is required as well.
50+
51+
When textile is installed locally:
52+
53+
bc.. pytest
54+
55+
When textile is not installed locally:
56+
57+
bc.. PYTHONPATH=. pytest

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[pytest]
22
testpaths = tests
3-
addopts = --cov=textile --cov-report=html --cov-append --cov-report=term-missing
3+
addopts = --cov=textile --cov-report=html --cov-append --cov-report=term-missing

setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,6 @@
44
import sys
55

66

7-
class PyTest(TestCommand):
8-
user_options = [('pytest-args=', 'a', "Arguments to pass to pytest")]
9-
10-
def initialize_options(self):
11-
TestCommand.initialize_options(self)
12-
self.pytest_args = []
13-
14-
def run_tests(self):
15-
import shlex
16-
#import here, cause outside the eggs aren't loaded
17-
import pytest
18-
errno = pytest.main(shlex.split(self.pytest_args))
19-
sys.exit(errno)
20-
21-
227
def get_version():
238
basedir = os.path.dirname(__file__)
249
with open(os.path.join(basedir, 'textile/version.py')) as f:
@@ -48,6 +33,7 @@ def get_version():
4833
'Programming Language :: Python :: 3.6',
4934
'Programming Language :: Python :: 3.7',
5035
'Programming Language :: Python :: 3.8',
36+
'Programming Language :: Python :: 3.9',
5137
'Topic :: Software Development :: Libraries :: Python Modules',
5238
],
5339
keywords='textile,text,html markup',
@@ -60,10 +46,8 @@ def get_version():
6046
'imagesize': ['Pillow>=3.0.0'],
6147
},
6248
entry_points={'console_scripts': ['pytextile=textile.__main__:main']},
63-
setup_requires=['pytest-runner'],
6449
tests_require=['pytest', 'pytest-cov'],
65-
cmdclass = {'test': PyTest},
6650
include_package_data=True,
6751
zip_safe=False,
68-
python_requires='~=3.5',
52+
python_requires='>=3.5',
6953
)

tests/fixtures/README.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<p><a href="https://travis-ci.org/textile/python-textile"><img alt="" src="https://travis-ci.org/textile/python-textile.svg" /></a> <a href="https://coveralls.io/github/textile/python-textile?branch=master"><img alt="" src="https://coveralls.io/repos/github/textile/python-textile/badge.svg" /></a> <a href="https://codecov.io/github/textile/python-textile"><img alt="" src="https://codecov.io/github/textile/python-textile/coverage.svg" /></a> <img alt="" src="https://img.shields.io/pypi/pyversions/textile" /> <img alt="" src="https://img.shields.io/pypi/wheel/textile" /></p>
1+
<p><a href="https://travis-ci.org/textile/python-textile"><img alt="" src="https://travis-ci.org/textile/python-textile.svg" /></a> <a href="https://codecov.io/github/textile/python-textile"><img alt="" src="https://codecov.io/github/textile/python-textile/coverage.svg" /></a> <img alt="" src="https://img.shields.io/pypi/pyversions/textile" /> <img alt="" src="https://img.shields.io/pypi/wheel/textile" /></p>
22

33
<h1>python-textile</h1>
44

@@ -48,4 +48,16 @@
4848

4949
<ul>
5050
<li>Active development supports Python 3.5 or later.</li>
51-
</ul>
51+
</ul>
52+
53+
<h3>Running Tests</h3>
54+
55+
<p>To run the test suite, use pytest. `pytest-cov` is required as well.</p>
56+
57+
<p>When textile is installed locally:</p>
58+
59+
<pre><code>pytest
60+
61+
When textile is not installed locally:</code></pre>
62+
63+
<pre>PYTHONPATH=. pytest</pre>

tests/test_getRefs.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,13 @@ def test_getRefs():
99
result = t.urlrefs
1010
expect = {'Google': 'http://www.google.com'}
1111
assert result == expect
12+
13+
t2 = Textile()
14+
15+
result = t2.getRefs("my ftp [ftp]ftp://example.com")
16+
expect = 'my ftp '
17+
assert result == expect
18+
19+
result = t2.urlrefs
20+
expect = {'ftp': 'ftp://example.com'}
21+
assert result == expect

textile/core.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,15 @@ def __init__(self, restricted=False, lite=False, noimage=False,
212212
else:
213213
self.url_schemes = self.unrestricted_url_schemes
214214

215+
all_schemes_re_s = '|'.join([
216+
'(?:{0})'.format(scheme)
217+
for scheme in self.url_schemes
218+
])
219+
self.url_ref_regex = re.compile(
220+
r'(?:(?<=^)|(?<=\s))\[(.+)\]\s?((?:{0}:\/\/|\/)\S+)(?=\s|$)'.format(all_schemes_re_s),
221+
re.U
222+
)
223+
215224
def parse(self, text, rel=None, sanitize=False):
216225
"""Parse the input text as textile and return html output."""
217226
self.notes = OrderedDict()
@@ -612,10 +621,7 @@ def glyphs(self, text):
612621

613622
def getRefs(self, text):
614623
"""Capture and store URL references in self.urlrefs."""
615-
pattern = re.compile(r'(?:(?<=^)|(?<=\s))\[(.+)\]((?:http(?:s?):\/\/|\/)\S+)(?=\s|$)',
616-
re.U)
617-
text = pattern.sub(self.refs, text)
618-
return text
624+
return self.url_ref_regex.sub(self.refs, text)
619625

620626
def refs(self, match):
621627
flag, url = match.groups()

textile/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = '4.0.1'
1+
VERSION = '4.0.2'

0 commit comments

Comments
 (0)