Skip to content

Commit 576c047

Browse files
author
Steve Canny
committed
shr: add ElementProxy.element
1 parent 71f4d03 commit 576c047

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

docx/shared.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ def __ne__(self, other):
194194
return True
195195
return self._element is not other._element
196196

197+
@property
198+
def element(self):
199+
"""
200+
The lxml element proxied by this object.
201+
"""
202+
return self._element
203+
197204

198205
class Parented(object):
199206
"""

tests/test_shared.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,18 @@ def it_knows_when_its_equal_to_another_proxy_object(self, eq_fixture):
2828
assert (proxy != proxy_3) is True
2929
assert (proxy != not_a_proxy) is True
3030

31+
def it_knows_its_element(self, element_fixture):
32+
proxy, element = element_fixture
33+
assert proxy.element is element
34+
3135
# fixture --------------------------------------------------------
3236

37+
@pytest.fixture
38+
def element_fixture(self):
39+
p = element('w:p')
40+
proxy = ElementProxy(p)
41+
return proxy, p
42+
3343
@pytest.fixture
3444
def eq_fixture(self):
3545
p, q = element('w:p'), element('w:p')

0 commit comments

Comments
 (0)