Skip to content

Commit e3bf347

Browse files
committed
3.0rc
1 parent 9082227 commit e3bf347

13 files changed

+76
-27
lines changed

.github/workflows/ci.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
python: ["3"]
1818
os: ["ubuntu-latest"]
1919
include:
20-
- {python: "3.7", os: "ubuntu-22.04"}
21-
- {python: "3.8", os: "ubuntu-22.04"}
2220
- {python: "3.9", os: "ubuntu-22.04"}
2321
- {python: "3.10", os: "ubuntu-22.04"}
2422
- {python: "3.11", os: "ubuntu-22.04"}
2523
- {python: "3.12", os: "ubuntu-22.04"}
24+
- {python: "3.13", os: "ubuntu-24.04"}
25+
- {python: "pypy3.10", os: "ubuntu-24.04"}
2626
steps:
2727
- uses: actions/checkout@v3
2828
- name: "Set up Python ${{ matrix.python }}"
@@ -33,7 +33,6 @@ jobs:
3333
run: |
3434
# python -m pip install --upgrade pip
3535
python -m pip install pytest
36-
python -m pip install mock
3736
python -m pip install flake8
3837
python -m pip install importlib_metadata
3938
python -m pip install "setuptools>=62"
@@ -48,13 +47,13 @@ jobs:
4847
run: |
4948
python -m build --no-isolation
5049
pip install dist/dominate*.tar.gz
51-
pytest
50+
pytest --ignore=tests/community
5251
- name: Coveralls
5352
env:
5453
COVERAGE_RCFILE: ".github/workflows/.coveragerc"
5554
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5655
run: |
5756
python -m pip install coverage
5857
python -m pip install coveralls
59-
coverage run --source=dominate -m pytest
58+
coverage run --source=dominate -m pytest --ignore=tests/community
6059
python -m coveralls --service=github || true

CONTRIBUTING.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
# 1. Welcome additions
3+
4+
Anything that is part of the official HTML spec is likely welcome.
5+
6+
Common patterns of web development, or ease-of-use features are welcome, so long as they are general and are likely to be useful to a broad group and not targetting any specific implimentation.
7+
8+
## 1.1. Testing
9+
10+
All PRs must have 100% test coverage of new code.
11+
12+
New features should include example usage, including motivations.
13+
14+
15+
16+
# 2. Not interested
17+
18+
For exceptions to these, see #Community
19+
20+
## 2.2. No 3rd party dependencies
21+
22+
Do not add 3rd party dependencies.
23+
24+
## 2.3. No 3rd party integrations
25+
26+
I am not interested in maintaining integrations with a bunch of random JS/web frameworks/libraries. (i.e. HTMX, Flask, Unpoly, whatever)
27+
28+
29+
# 3. Community Packages
30+
31+
If you wish to add a feature that would otherwise be disallowed by the above, you can make a community package. See `community/htmx.py` for a trivial example.
32+
33+
Community packages must not be referenced from the main library, and must not do anything unless explicitly imported.
34+

Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
test:
2-
-python2 -m pytest .
2+
python3 -m pytest . --ignore=tests/community
3+
4+
test-community:
35
python3 -m pytest .
46

57
publish_old: clean test

dominate/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.9.1'
1+
__version__ = '3.0.0'

dominate/community/htmx.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
from .. import tags
3+
4+
class HtmxTag:
5+
@classmethod
6+
def clean_attribute(cls, attribute):
7+
attribute = super().clean_attribute(attribute)
8+
if attribute.startswith('hx_'):
9+
attribute = attribute.replace('_', '-')
10+
return attribute
11+
12+
tags.html_tag.__bases__ = (HtmxTag,) + tags.html_tag.__bases__

dominate/dom_tag.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def clean_attribute(attribute):
441441
}.get(attribute, attribute)
442442

443443
# Workaround for Python's reserved words
444-
if attribute[0] == '_':
444+
if attribute[0] == '_' and len(attribute) > 1:
445445
attribute = attribute[1:]
446446

447447
# Workaround for dash

tests/community/test_htmx.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
from dominate import tags
3+
import dominate.community.htmx
4+
5+
def test_hx():
6+
d = tags.div(hx_foo=1)
7+
assert d.render() == '<div hx-foo="1"></div>'

tests/test_document.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from dominate import document
22
from dominate.tags import *
33

4+
45
def test_doc():
56
d = document()
67
assert d.render() == \

tests/test_dom_tag.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import pytest
2-
try:
3-
import mock
4-
except ImportError:
5-
import unittest.mock as mock
2+
import unittest.mock as mock
63

74
from dominate.tags import *
85

tests/test_dom_tag_async.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from asyncio import gather, run, Semaphore
2-
from dominate.dom_tag import async_context_id
32
from textwrap import dedent
43

54
from dominate import tags
5+
from dominate.dom_tag import async_context_id
6+
67

78
# To simulate sleep without making the tests take a hella long time to complete
89
# lets use a pair of semaphores to explicitly control when our coroutines run.
@@ -28,7 +29,7 @@ async def merge():
2829
sem_1 = Semaphore(0)
2930
sem_2 = Semaphore(0)
3031
return await gather(
31-
tag_routine_1(sem_1, sem_2),
32+
tag_routine_1(sem_1, sem_2),
3233
tag_routine_2(sem_1, sem_2)
3334
)
3435

@@ -67,7 +68,7 @@ async def merge():
6768
<div id="2"></div>
6869
</div>
6970
""").strip()
70-
71+
7172
assert tag_2 == dedent("""\
7273
<div id="3">
7374
<div id="4"></div>

tests/test_dominate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
def test_version():
33
import dominate
4-
version = '2.9.1'
4+
version = '3.0.0'
55
assert dominate.version == version
66
assert dominate.__version__ == version

tests/test_html.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
import dominate
2-
from dominate.tags import *
31
import pytest
4-
from dominate.util import raw
52

6-
try:
7-
xrange = xrange
8-
except NameError:
9-
xrange = range
3+
from dominate.tags import *
4+
from dominate.util import raw
105

116

127
def test_arguments():
@@ -43,7 +38,7 @@ def test_add():
4338
with pytest.raises(ValueError):
4439
d += None
4540
d += 1
46-
d += xrange(2,3)
41+
d += range(2,3)
4742
d += {'id': 'foo'}
4843
assert d.render() == '<div id="foo">12</div>'
4944
assert len(d) == 2
@@ -208,6 +203,9 @@ def test_attributes():
208203
with pytest.raises(AttributeError):
209204
x = d['id']
210205

206+
with div(_foo='a', _='b') as d:
207+
assert d.attributes.keys() == {'foo', '_'}
208+
211209
with div() as d:
212210
attr(data_test=False)
213211
assert d['data-test'] is False
@@ -329,7 +327,7 @@ def test_pretty():
329327

330328
assert p('goodbye ', i('cruel'), ' world').render() == \
331329
'''<p>goodbye <i>cruel</i> world</p>'''
332-
330+
333331
assert p('my 1', sup('st'), ' PR').render() == \
334332
'''<p>my 1<sup>st</sup> PR</p>'''
335333

tests/test_svg.py

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
from dominate.tags import *
55
from dominate.svg import *
66

7-
import pytest
8-
97

108
def base():
119
return svg(

0 commit comments

Comments
 (0)