minor fixes

This commit is contained in:
lilydjwg 2021-06-11 16:10:34 +08:00
parent d2c7d48a2f
commit a969f12d20
9 changed files with 13 additions and 11 deletions

View file

@ -41,7 +41,7 @@ jobs:
if: ${{ contains(matrix.deps, 'pycurl') }} if: ${{ contains(matrix.deps, 'pycurl') }}
run: sudo apt install -y libcurl4-openssl-dev run: sudo apt install -y libcurl4-openssl-dev
- name: Install Python deps - name: Install Python deps
run: pip install -U ${{ matrix.deps }} pytest pytest-asyncio pytest-httpbin flaky structlog toml appdirs run: pip install -U ${{ matrix.deps }} pytest pytest-asyncio pytest-httpbin flaky structlog toml appdirs lxml
- name: Decrypt keys - name: Decrypt keys
env: env:
KEY: ${{ secrets.KEY }} KEY: ${{ secrets.KEY }}

View file

@ -286,7 +286,7 @@ xpath
An xpath expression used to find the version string. An xpath expression used to find the version string.
.. note:: .. note::
An additional dependency "lxml" is required An additional dependency "lxml" is required.
Find with a Command Find with a Command
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~

View file

@ -20,3 +20,6 @@ ignore_missing_imports = True
[mypy-appdirs] [mypy-appdirs]
ignore_missing_imports = True ignore_missing_imports = True
[mypy-lxml]
ignore_missing_imports = True

View file

@ -8,4 +8,4 @@ from .util import (
) )
from .sortversion import sort_version_keys from .sortversion import sort_version_keys
from .ctxvars import tries, proxy, user_agent, httptoken, entry_waiter from .ctxvars import tries, proxy, user_agent, httptoken, entry_waiter

View file

@ -17,4 +17,4 @@ tries = ContextVar('tries', default=1)
proxy: ContextVar[Optional[str]] = ContextVar('proxy', default=None) proxy: ContextVar[Optional[str]] = ContextVar('proxy', default=None)
user_agent = ContextVar('user_agent', default=DEFAULT_USER_AGENT) user_agent = ContextVar('user_agent', default=DEFAULT_USER_AGENT)
httptoken = ContextVar('httptoken', default=None) httptoken = ContextVar('httptoken', default=None)
entry_waiter: ContextVar[EntryWaiter] = ContextVar('entry_waiter') entry_waiter: ContextVar[EntryWaiter] = ContextVar('entry_waiter')

View file

@ -264,7 +264,6 @@ class FunctionWorker(BaseWorker):
except Exception as e: except Exception as e:
await self.result_q.put(RawResult(name, e, entry)) await self.result_q.put(RawResult(name, e, entry))
class GetVersionError(Exception): class GetVersionError(Exception):
'''An error occurred while getting version information. '''An error occurred while getting version information.

View file

@ -18,4 +18,4 @@ async def test_xpath_missing_ok(get_version):
"url": "http://httpbin.org/", "url": "http://httpbin.org/",
"xpath": '//pre[@class="test-is-ok"]/text()', "xpath": '//pre[@class="test-is-ok"]/text()',
"missing_ok": True, "missing_ok": True,
}) is None }) is None

View file

@ -3,7 +3,7 @@
import pytest import pytest
import pytest_httpbin import pytest_httpbin
assert pytest_httpbin # for pyflakes assert pytest_httpbin # for pyflakes
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
async def test_redirection(get_version): async def test_redirection(get_version):
@ -11,7 +11,7 @@ async def test_redirection(get_version):
"source": "httpheader", "source": "httpheader",
"url": "https://www.unifiedremote.com/download/linux-x64-deb", "url": "https://www.unifiedremote.com/download/linux-x64-deb",
"regex": r'urserver-([\d.]+).deb', "regex": r'urserver-([\d.]+).deb',
}) != None }) is not None
async def test_get_version_withtoken(get_version, httpbin): async def test_get_version_withtoken(get_version, httpbin):
assert await get_version("unifiedremote", { assert await get_version("unifiedremote", {
@ -20,4 +20,4 @@ async def test_get_version_withtoken(get_version, httpbin):
"httptoken": "Basic dXNlcm5hbWU6c3VwZXJwYXNzd29yZA==", "httptoken": "Basic dXNlcm5hbWU6c3VwZXJwYXNzd29yZA==",
"header": "server", "header": "server",
"regex": r'([0-9.]+)*', "regex": r'([0-9.]+)*',
}) != None }) is not None

View file

@ -5,7 +5,7 @@ import base64
import pytest import pytest
import pytest_httpbin import pytest_httpbin
assert pytest_httpbin # for pyflakes assert pytest_httpbin # for pyflakes
pytestmark = pytest.mark.asyncio pytestmark = pytest.mark.asyncio
@ -57,4 +57,4 @@ async def test_regex_with_tokenBearer(get_version, httpbin):
"url": httpbin.url + "/bearer", "url": httpbin.url + "/bearer",
"httptoken": "Bearer username:password", "httptoken": "Bearer username:password",
"regex": r'"token":"([a-w]+):.*"', "regex": r'"token":"([a-w]+):.*"',
}) == "username" }) == "username"