<s> import mimetypes <EOL> from lassie . core import Lassie <EOL> from lassie . compat import urlparse <EOL> from mock import patch <EOL> import unittest <EOL> def _mock_retrieve_content ( mock , url ) : <EOL> filename = urlparse ( url ) . path <EOL> _file = open ( '<STR_LIT>' % filename , '<STR_LIT:r>' ) <EOL> content = _file . read ( ) <EOL> _file . close ( ) <EOL> return content <EOL> def _mock_retrieve_headers ( mock , url ) : <EOL> filename = urlparse ( url ) . path <EOL> headers = { <EOL> '<STR_LIT:Content-Type>' : mimetypes . guess_type ( filename ) [ <NUM_LIT:0> ] or '<STR_LIT>' <EOL> } <EOL> return headers <EOL> class LassieBaseTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . patch = patch . object ( Lassie , '<STR_LIT>' , _mock_retrieve_content ) <EOL> self . patch2 = patch . object ( Lassie , '<STR_LIT>' , _mock_retrieve_headers ) <EOL> self . patch . start ( ) <EOL> self . patch2 . start ( ) <EOL> def tearDown ( self ) : <EOL> self . patch . stop ( ) <EOL> self . patch2 . stop ( ) </s>
