Skip to content

Commit

Permalink
Update CI tests
Browse files Browse the repository at this point in the history
  - Full py313 test, add py314 tests with alpha1 version
  - Fix unicode installation tests with Unicode data >= 16.0.0
  • Loading branch information
brunato committed Oct 27, 2024
1 parent bedfc3d commit bb86e03
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test-elementpath.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.8, 3.9, "3.10", 3.11, 3.12, "3.13.0", "pypy-3.10"]
python-version: [3.8, 3.9, "3.10", 3.11, 3.12, "3.13.0", "3.14.0-alpha.1", "pypy-3.10"]
exclude:
- os: macos-latest
python-version: 3.8
Expand All @@ -41,10 +41,10 @@ jobs:
flake8 elementpath --max-line-length=100 --statistics
- name: Lint with mypy
run: |
pip install mypy==1.11.2 xmlschema lxml-stubs
pip install mypy==1.13.0 xmlschema lxml-stubs
mypy --show-error-codes --strict elementpath
- name: Install optional dependencies
if: ${{ matrix.python-version != '3.13.0' }}
if: ${{ matrix.python-version != '3.14.0-alpha.1' }}
run: pip install lxml
- name: Test with unittest
run: |
Expand Down
3 changes: 2 additions & 1 deletion elementpath/xpath31/_xpath31_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,8 @@ def decode_value(value: SequenceType[ItemType]) -> ItemType:
)

def json_object_pairs_to_map(obj: Iterable[Tuple[str, SequenceType[ItemType]]]) -> XPathMap:
items = {}
items: Dict[ItemType, SequenceType[ItemType]] = {}

for item in obj:
key, value = decode_value(item[0]), decode_value(item[1])
if key in items:
Expand Down
32 changes: 32 additions & 0 deletions tests/test_regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ def test_others_unicode_blocks(self):
ncp = len(unicode_block('GreekandCoptic') - unicode_category('Cn'))
self.assertEqual(ncp, 135)

@unittest.skipIf(unidata_version[:2] >= '16', f"Unicode {unidata_version} is installed")
def test_install_unicode_data(self):
self.assertEqual(unidata_version, unicode_version())
self.assertNotIn(42971, unicode_category('Ll'))
Expand Down Expand Up @@ -734,6 +735,37 @@ def test_install_unicode_data(self):

self.assertEqual(unidata_version, unicode_version())

@unittest.skipIf(unidata_version[:2] < '16', f"Unicode {unidata_version} is installed")
def test_install_previous_unicode_data(self):
self.assertEqual(unidata_version, unicode_version())
self.assertIn(42971, unicode_category('Ll'))

install_unicode_data('15.0.0')
self.assertEqual('15.0.0', unicode_version())
self.assertNotIn(42971, unicode_category('Ll'))

install_unicode_data()
self.assertEqual(unidata_version, unicode_version())
self.assertIn(42971, unicode_category('Ll'))

install_unicode_data('15.0.0', 'elementpath.regex.unicode_categories')
self.assertEqual('15.0.0', unicode_version())
self.assertNotIn(42971, unicode_category('Ll'))

install_unicode_data()
self.assertEqual(unidata_version, unicode_version())
self.assertIn(42971, unicode_category('Ll'))

with self.assertRaises(ValueError) as ctx:
install_unicode_data('14.1.0')
self.assertEqual(str(ctx.exception), "argument is not a valid Unicode version")

with self.assertRaises(TypeError) as ctx:
install_unicode_data(name_or_url='elementpath.regex.unicode_categories')
self.assertEqual(str(ctx.exception), "you must specify a version to install")

self.assertEqual(unidata_version, unicode_version())

@unittest.skipUnless('TEST_UNICODE_INSTALLATION' in os.environ,
"Skip UnicodeData.txt installation")
def test_unicode_data_installation_from_source(self):
Expand Down
13 changes: 9 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
[tox]
min_version = 4.0
envlist =
py{38,39,310,311,312,313}, pypy3, docs, flake8,
mypy-py{38,39,310,311,312,py3}, pytest, coverage,
py{38,39,310,311,312,313,314}, pypy3, docs, flake8,
mypy-py{38,39,310,311,312,313,py3}, pytest, coverage,
xmlschema{251,302,310,321,332,342}, w3c-xsdtests
skip_missing_interpreters = true
work_dir = {tox_root}/../.tox/elementpath
Expand All @@ -23,6 +23,11 @@ set_env =
py313: TEST_UNICODE_INSTALLATION = 6.2.0
commands = python -m unittest

[testenv:py314]
deps =
elementpath>=4.4.0, <5.0.0
jinja2

[testenv:docs]
commands =
make -C doc html SPHINXOPTS="-W -n"
Expand All @@ -41,9 +46,9 @@ commands =
flake8 elementpath
flake8 tests

[testenv:mypy-py{38,39,310,311,312,py3}]
[testenv:mypy-py{38,39,310,311,312,313,py3}]
deps =
mypy==1.11.2
mypy==1.13.0
xmlschema>=3.1.0
lxml-stubs
commands =
Expand Down

0 comments on commit bb86e03

Please sign in to comment.