15
15
16
16
import pytest
17
17
18
- from ..unitutil .cxml import element
18
+ from ..unitutil .cxml import element , xml
19
19
from ..unitutil .mock import call , class_mock , instance_mock
20
20
21
21
@@ -25,6 +25,12 @@ def it_knows_its_position(self, position_get_fixture):
25
25
tab_stop , expected_value = position_get_fixture
26
26
assert tab_stop .position == expected_value
27
27
28
+ def it_can_change_its_position (self , position_set_fixture ):
29
+ tab_stop , value , tabs , new_idx , expected_xml = position_set_fixture
30
+ tab_stop .position = value
31
+ assert tab_stop ._tab is tabs [new_idx ]
32
+ assert tabs .xml == expected_xml
33
+
28
34
def it_knows_its_alignment (self , alignment_get_fixture ):
29
35
tab_stop , expected_value = alignment_get_fixture
30
36
assert tab_stop .alignment == expected_value
@@ -61,6 +67,31 @@ def position_get_fixture(self, request):
61
67
tab_stop = TabStop (element ('w:tab{w:pos=720}' ))
62
68
return tab_stop , Twips (720 )
63
69
70
+ @pytest .fixture (params = [
71
+ ('w:tabs/w:tab{w:pos=360,w:val=left}' ,
72
+ Twips (720 ), 0 ,
73
+ 'w:tabs/w:tab{w:pos=720,w:val=left}' ),
74
+ ('w:tabs/(w:tab{w:pos=360,w:val=left},w:tab{w:pos=720,w:val=left})' ,
75
+ Twips (180 ), 0 ,
76
+ 'w:tabs/(w:tab{w:pos=180,w:val=left},w:tab{w:pos=720,w:val=left})' ),
77
+ ('w:tabs/(w:tab{w:pos=360,w:val=left},w:tab{w:pos=720,w:val=left})' ,
78
+ Twips (960 ), 1 ,
79
+ 'w:tabs/(w:tab{w:pos=720,w:val=left},w:tab{w:pos=960,w:val=left})' ),
80
+ ('w:tabs/(w:tab{w:pos=-72,w:val=left},w:tab{w:pos=-36,w:val=left})' ,
81
+ Twips (- 48 ), 0 ,
82
+ 'w:tabs/(w:tab{w:pos=-48,w:val=left},w:tab{w:pos=-36,w:val=left})' ),
83
+ ('w:tabs/(w:tab{w:pos=-72,w:val=left},w:tab{w:pos=-36,w:val=left})' ,
84
+ Twips (- 16 ), 1 ,
85
+ 'w:tabs/(w:tab{w:pos=-36,w:val=left},w:tab{w:pos=-16,w:val=left})' ),
86
+ ])
87
+ def position_set_fixture (self , request ):
88
+ tabs_cxml , value , new_idx , expected_cxml = request .param
89
+ tabs = element (tabs_cxml )
90
+ tab = tabs .tab_lst [0 ]
91
+ tab_stop = TabStop (tab )
92
+ expected_xml = xml (expected_cxml )
93
+ return tab_stop , value , tabs , new_idx , expected_xml
94
+
64
95
65
96
class DescribeTabStops (object ):
66
97
0 commit comments