<s> """<STR_LIT>""" <EOL> from __future__ import ( <EOL> absolute_import , division , print_function , unicode_literals <EOL> ) <EOL> import pytest <EOL> import docx <EOL> from docx . api import Document <EOL> from docx . opc . constants import CONTENT_TYPE as CT <EOL> from . unitutil . mock import function_mock , instance_mock , class_mock <EOL> class DescribeDocument ( object ) : <EOL> def it_opens_a_docx_file ( self , open_fixture ) : <EOL> docx , Package_ , document_ = open_fixture <EOL> document = Document ( docx ) <EOL> Package_ . open . assert_called_once_with ( docx ) <EOL> assert document is document_ <EOL> def it_opens_the_default_docx_if_none_specified ( self , default_fixture ) : <EOL> docx , Package_ , document_ = default_fixture <EOL> document = Document ( ) <EOL> Package_ . open . assert_called_once_with ( docx ) <EOL> assert document is document_ <EOL> def it_raises_on_not_a_Word_file ( self , raise_fixture ) : <EOL> not_a_docx = raise_fixture <EOL> with pytest . raises ( ValueError ) : <EOL> Document ( not_a_docx ) <EOL> @ pytest . fixture <EOL> def default_fixture ( self , _default_docx_path_ , Package_ , document_ ) : <EOL> docx = '<STR_LIT>' <EOL> _default_docx_path_ . return_value = docx <EOL> document_part = Package_ . open . return_value . main_document_part <EOL> document_part . document = document_ <EOL> document_part . content_type = CT . WML_DOCUMENT_MAIN <EOL> return docx , Package_ , document_ <EOL> @ pytest . fixture <EOL> def open_fixture ( self , Package_ , document_ ) : <EOL> docx = '<STR_LIT>' <EOL> document_part = Package_ . open . return_value . main_document_part <EOL> document_part . document = document_ <EOL> document_part . content_type = CT . WML_DOCUMENT_MAIN <EOL> return docx , Package_ , document_ <EOL> @ pytest . fixture <EOL> def raise_fixture ( self , Package_ ) : <EOL> not_a_docx = '<STR_LIT>' <EOL> Package_ . open . return_value . main_document_part . content_type = '<STR_LIT>' <EOL> return not_a_docx <EOL> @ pytest . fixture <EOL> def _default_docx_path_ ( self , request ) : <EOL> return function_mock ( request , '<STR_LIT>' ) <EOL> @ pytest . fixture <EOL> def document_ ( self , request ) : <EOL> return instance_mock ( request , docx . document . Document ) <EOL> @ pytest . fixture <EOL> def Package_ ( self , request ) : <EOL> return class_mock ( request , '<STR_LIT>' ) </s>
