11# encoding: utf-8
22
3- """
4- Step implementations for document settings-related features
5- """
3+ """Step implementations for document settings-related features"""
64
7- from __future__ import (
8- absolute_import , division , print_function , unicode_literals
9- )
5+ from __future__ import absolute_import , division , print_function , unicode_literals
106
11- from behave import given , then
7+ from behave import given , then , when
128
139from docx import Document
1410from docx .settings import Settings
@@ -28,9 +24,33 @@ def given_a_document_having_no_settings_part(context):
2824 context .document = Document (test_docx ('set-no-settings-part' ))
2925
3026
27+ @given ("a Settings object {with_or_without} odd and even page headers as settings" )
28+ def given_a_Settings_object_with_or_without_odd_and_even_hdrs (context , with_or_without ):
29+ testfile_name = {
30+ "with" : "doc-odd-even-hdrs" , "without" : "sct-section-props"
31+ }[with_or_without ]
32+ context .settings = Document (test_docx (testfile_name )).settings
33+
34+
35+ # when =====================================================
36+
37+ @when ("I assign {bool_val} to settings.odd_and_even_pages_header_footer" )
38+ def when_I_assign_value_to_settings_odd_and_even_pages_header_footer (context , bool_val ):
39+ context .settings .odd_and_even_pages_header_footer = eval (bool_val )
40+
41+
3142# then =====================================================
3243
3344@then ('document.settings is a Settings object' )
3445def then_document_settings_is_a_Settings_object (context ):
3546 document = context .document
3647 assert type (document .settings ) is Settings
48+
49+
50+ @then ("settings.odd_and_even_pages_header_footer is {bool_val}" )
51+ def then_settings_odd_and_even_pages_header_footer_is (context , bool_val ):
52+ actual = context .settings .odd_and_even_pages_header_footer
53+ expected = eval (bool_val )
54+ assert actual == expected , (
55+ "settings.odd_and_even_pages_header_footer is %s" % actual
56+ )
0 commit comments