5
5
from docx .enum .style import WD_STYLE_TYPE
6
6
from docx .styles .style import (
7
7
BaseStyle ,
8
+ CharacterStyle ,
9
+ ParagraphStyle ,
8
10
StyleFactory ,
9
- _CharacterStyle ,
10
11
_NumberingStyle ,
11
- _ParagraphStyle ,
12
12
_TableStyle ,
13
13
)
14
14
from docx .text .font import Font
@@ -32,18 +32,18 @@ def factory_fixture(
32
32
self ,
33
33
request ,
34
34
paragraph_style_ ,
35
- _ParagraphStyle_ ,
35
+ ParagraphStyle_ ,
36
36
character_style_ ,
37
- _CharacterStyle_ ,
37
+ CharacterStyle_ ,
38
38
table_style_ ,
39
39
_TableStyle_ ,
40
40
numbering_style_ ,
41
41
_NumberingStyle_ ,
42
42
):
43
43
type_attr_val = request .param
44
44
StyleCls_ , style_mock = {
45
- "paragraph" : (_ParagraphStyle_ , paragraph_style_ ),
46
- "character" : (_CharacterStyle_ , character_style_ ),
45
+ "paragraph" : (ParagraphStyle_ , paragraph_style_ ),
46
+ "character" : (CharacterStyle_ , character_style_ ),
47
47
"table" : (_TableStyle_ , table_style_ ),
48
48
"numbering" : (_NumberingStyle_ , numbering_style_ ),
49
49
}[request .param ]
@@ -54,24 +54,24 @@ def factory_fixture(
54
54
# fixture components -----------------------------------
55
55
56
56
@pytest .fixture
57
- def _ParagraphStyle_ (self , request , paragraph_style_ ):
57
+ def ParagraphStyle_ (self , request , paragraph_style_ ):
58
58
return class_mock (
59
- request , "docx.styles.style._ParagraphStyle " , return_value = paragraph_style_
59
+ request , "docx.styles.style.ParagraphStyle " , return_value = paragraph_style_
60
60
)
61
61
62
62
@pytest .fixture
63
63
def paragraph_style_ (self , request ):
64
- return instance_mock (request , _ParagraphStyle )
64
+ return instance_mock (request , ParagraphStyle )
65
65
66
66
@pytest .fixture
67
- def _CharacterStyle_ (self , request , character_style_ ):
67
+ def CharacterStyle_ (self , request , character_style_ ):
68
68
return class_mock (
69
- request , "docx.styles.style._CharacterStyle " , return_value = character_style_
69
+ request , "docx.styles.style.CharacterStyle " , return_value = character_style_
70
70
)
71
71
72
72
@pytest .fixture
73
73
def character_style_ (self , request ):
74
- return instance_mock (request , _CharacterStyle )
74
+ return instance_mock (request , CharacterStyle )
75
75
76
76
@pytest .fixture
77
77
def _TableStyle_ (self , request , table_style_ ):
@@ -396,7 +396,7 @@ def unhide_set_fixture(self, request):
396
396
return style , value , expected_xml
397
397
398
398
399
- class Describe_CharacterStyle (object ):
399
+ class DescribeCharacterStyle (object ):
400
400
def it_knows_which_style_it_is_based_on (self , base_get_fixture ):
401
401
style , StyleFactory_ , StyleFactory_calls , base_style_ = base_get_fixture
402
402
base_style = style .base_style
@@ -427,7 +427,7 @@ def it_provides_access_to_its_font(self, font_fixture):
427
427
def base_get_fixture (self , request , StyleFactory_ ):
428
428
styles_cxml , style_idx , base_style_idx = request .param
429
429
styles = element (styles_cxml )
430
- style = _CharacterStyle (styles [style_idx ])
430
+ style = CharacterStyle (styles [style_idx ])
431
431
if base_style_idx >= 0 :
432
432
base_style = styles [base_style_idx ]
433
433
StyleFactory_calls = [call (base_style )]
@@ -446,15 +446,15 @@ def base_get_fixture(self, request, StyleFactory_):
446
446
)
447
447
def base_set_fixture (self , request , style_ ):
448
448
style_cxml , base_style_id , expected_style_cxml = request .param
449
- style = _CharacterStyle (element (style_cxml ))
449
+ style = CharacterStyle (element (style_cxml ))
450
450
style_ .style_id = base_style_id
451
451
base_style = style_ if base_style_id is not None else None
452
452
expected_xml = xml (expected_style_cxml )
453
453
return style , base_style , expected_xml
454
454
455
455
@pytest .fixture
456
456
def font_fixture (self , Font_ , font_ ):
457
- style = _CharacterStyle (element ("w:style" ))
457
+ style = CharacterStyle (element ("w:style" ))
458
458
return style , Font_ , font_
459
459
460
460
# fixture components ---------------------------------------------
@@ -476,7 +476,7 @@ def StyleFactory_(self, request):
476
476
return function_mock (request , "docx.styles.style.StyleFactory" )
477
477
478
478
479
- class Describe_ParagraphStyle (object ):
479
+ class DescribeParagraphStyle (object ):
480
480
def it_knows_its_next_paragraph_style (self , next_get_fixture ):
481
481
style , expected_value = next_get_fixture
482
482
assert style .next_paragraph_style == expected_value
@@ -515,8 +515,8 @@ def next_get_fixture(self, request):
515
515
style_names = ["H1" , "H2" , "Body" , "Foo" , "Char" ]
516
516
style_elm = styles [style_names .index (style_name )]
517
517
next_style_elm = styles [style_names .index (next_style_name )]
518
- style = _ParagraphStyle (style_elm )
519
- next_style = _ParagraphStyle (next_style_elm ) if style_name == "H1" else style
518
+ style = ParagraphStyle (style_elm )
519
+ next_style = ParagraphStyle (next_style_elm ) if style_name == "H1" else style
520
520
return style , next_style
521
521
522
522
@pytest .fixture (
@@ -534,18 +534,18 @@ def next_set_fixture(self, request):
534
534
"w:style{w:type=paragraph,w:styleId=B})"
535
535
)
536
536
style_elms = {"H" : styles [0 ], "B" : styles [1 ]}
537
- style = _ParagraphStyle (style_elms [style_name ])
537
+ style = ParagraphStyle (style_elms [style_name ])
538
538
next_style = (
539
539
None
540
540
if next_style_name is None
541
- else _ParagraphStyle (style_elms [next_style_name ])
541
+ else ParagraphStyle (style_elms [next_style_name ])
542
542
)
543
543
expected_xml = xml (style_cxml )
544
544
return style , next_style , expected_xml
545
545
546
546
@pytest .fixture
547
547
def parfmt_fixture (self , ParagraphFormat_ , paragraph_format_ ):
548
- style = _ParagraphStyle (element ("w:style" ))
548
+ style = ParagraphStyle (element ("w:style" ))
549
549
return style , ParagraphFormat_ , paragraph_format_
550
550
551
551
# fixture components ---------------------------------------------
0 commit comments