diff --git a/.travis.yml b/.travis.yml index d8c61e29..0b147e1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,10 @@ matrix: env: TOXENV=py35 - python: 3.6 env: TOXENV=py36 + - python: 3.7 + env: TOXENV=py37 + dist: xenial + sudo: true # command to install dependencies install: diff --git a/extruct/_extruct.py b/extruct/_extruct.py index 1e76bb64..c2323abf 100644 --- a/extruct/_extruct.py +++ b/extruct/_extruct.py @@ -39,7 +39,7 @@ def extract(htmlstring, base_url=None, encoding="UTF-8", schema_context: schema's context for current page""" if base_url is None and 'url' in kwargs: warnings.warn('"url" argument is deprecated, please use "base_url"', - DeprecationWarning) + DeprecationWarning, stacklevel=2) base_url = kwargs.pop('url') if kwargs: raise TypeError('Unexpected keyword arguments') diff --git a/extruct/jsonld.py b/extruct/jsonld.py index 706b061b..f11580eb 100644 --- a/extruct/jsonld.py +++ b/extruct/jsonld.py @@ -10,7 +10,7 @@ from extruct.utils import parse_html -HTML_OR_JS_COMMENTLINE = re.compile('^\s*(//.*|)') +HTML_OR_JS_COMMENTLINE = re.compile(r'^\s*(//.*|)') class JsonLdExtractor(object): diff --git a/extruct/tool.py b/extruct/tool.py index ce05368e..8e8f70fa 100644 --- a/extruct/tool.py +++ b/extruct/tool.py @@ -14,8 +14,8 @@ def metadata_from_url(url, syntaxes=SYNTAXES, uniform=False, resp.raise_for_status() except requests.exceptions.HTTPError: return result - result.update(extruct.extract(resp.content, - url=url, + result.update(extruct.extract(resp.content, + base_url=url, # FIXME: use base url syntaxes=syntaxes, uniform=uniform, schema_context=schema_context, diff --git a/setup.py b/setup.py index e7ea58ce..5bbc7553 100644 --- a/setup.py +++ b/setup.py @@ -57,5 +57,6 @@ def get_version(): 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', ], ) diff --git a/tests/test_extruct.py b/tests/test_extruct.py index f6b2a894..07360fdd 100644 --- a/tests/test_extruct.py +++ b/tests/test_extruct.py @@ -2,6 +2,8 @@ import json import unittest +import pytest + import extruct from tests import get_testdata, jsonize_dict, replace_node_ref_with_node_id @@ -31,8 +33,9 @@ def test_microdata_with_returning_node(self): def test_deprecated_url(self): body, expected = self._microdata_custom_url('product_custom_url.json') - data = extruct.extract(body, url='http://some-example.com', - syntaxes=['microdata']) + with pytest.warns(DeprecationWarning): + data = extruct.extract(body, url='http://some-example.com', + syntaxes=['microdata']) self.assertEqual(data, expected) def test_extra_kwargs(self): diff --git a/tox.ini b/tox.ini index e2bc2898..e5deb3eb 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, py34, py35, py36 +envlist = py27, py34, py35, py36, py37 [testenv] deps =