Skip to content

Commit f79972f

Browse files
committed
better Python 3.7 support
* added Python 3.7 to tests * fix Python 3.7 warnings * improve DeprecationWarning, so that it points to a caller code
1 parent 18f41f1 commit f79972f

File tree

7 files changed

+15
-7
lines changed

7 files changed

+15
-7
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ matrix:
1212
env: TOXENV=py35
1313
- python: 3.6
1414
env: TOXENV=py36
15+
- python: 3.7
16+
env: TOXENV=py37
17+
dist: xenial
18+
sudo: true
1519

1620
# command to install dependencies
1721
install:

extruct/_extruct.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def extract(htmlstring, base_url=None, encoding="UTF-8",
3939
schema_context: schema's context for current page"""
4040
if base_url is None and 'url' in kwargs:
4141
warnings.warn('"url" argument is deprecated, please use "base_url"',
42-
DeprecationWarning)
42+
DeprecationWarning, stacklevel=2)
4343
base_url = kwargs.pop('url')
4444
if kwargs:
4545
raise TypeError('Unexpected keyword arguments')

extruct/jsonld.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from extruct.utils import parse_html
1212

13-
HTML_OR_JS_COMMENTLINE = re.compile('^\s*(//.*|<!--.*-->)')
13+
HTML_OR_JS_COMMENTLINE = re.compile(r'^\s*(//.*|<!--.*-->)')
1414

1515

1616
class JsonLdExtractor(object):

extruct/tool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def metadata_from_url(url, syntaxes=SYNTAXES, uniform=False,
1414
resp.raise_for_status()
1515
except requests.exceptions.HTTPError:
1616
return result
17-
result.update(extruct.extract(resp.content,
18-
url=url,
17+
result.update(extruct.extract(resp.content,
18+
base_url=url, # FIXME: use base url
1919
syntaxes=syntaxes,
2020
uniform=uniform,
2121
schema_context=schema_context,

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@ def get_version():
5757
'Programming Language :: Python :: 3.4',
5858
'Programming Language :: Python :: 3.5',
5959
'Programming Language :: Python :: 3.6',
60+
'Programming Language :: Python :: 3.7',
6061
],
6162
)

tests/test_extruct.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import json
33
import unittest
44

5+
import pytest
6+
57
import extruct
68
from tests import get_testdata, jsonize_dict, replace_node_ref_with_node_id
79

@@ -31,8 +33,9 @@ def test_microdata_with_returning_node(self):
3133

3234
def test_deprecated_url(self):
3335
body, expected = self._microdata_custom_url('product_custom_url.json')
34-
data = extruct.extract(body, url='http://some-example.com',
35-
syntaxes=['microdata'])
36+
with pytest.warns(DeprecationWarning):
37+
data = extruct.extract(body, url='http://some-example.com',
38+
syntaxes=['microdata'])
3639
self.assertEqual(data, expected)
3740

3841
def test_extra_kwargs(self):

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py27, py34, py35, py36
2+
envlist = py27, py34, py35, py36, py37
33

44
[testenv]
55
deps =

0 commit comments

Comments
 (0)