<s> from unittest import TestCase <EOL> from sure import expect <EOL> from httpretty import httprettified , HTTPretty <EOL> try : <EOL> import urllib . request as urllib2 <EOL> except ImportError : <EOL> import urllib2 <EOL> @ httprettified <EOL> def test_decor ( ) : <EOL> HTTPretty . register_uri ( <EOL> HTTPretty . GET , "<STR_LIT>" , <EOL> body = "<STR_LIT>" ) <EOL> fd = urllib2 . urlopen ( '<STR_LIT>' ) <EOL> got1 = fd . read ( ) <EOL> fd . close ( ) <EOL> expect ( got1 ) . to . equal ( b'<STR_LIT>' ) <EOL> @ httprettified <EOL> class ClassDecorator ( TestCase ) : <EOL> def test_decorated ( self ) : <EOL> HTTPretty . register_uri ( <EOL> HTTPretty . GET , "<STR_LIT>" , <EOL> body = "<STR_LIT>" ) <EOL> fd = urllib2 . urlopen ( '<STR_LIT>' ) <EOL> got1 = fd . read ( ) <EOL> fd . close ( ) <EOL> expect ( got1 ) . to . equal ( b'<STR_LIT>' ) <EOL> def test_decorated2 ( self ) : <EOL> HTTPretty . register_uri ( <EOL> HTTPretty . GET , "<STR_LIT>" , <EOL> body = "<STR_LIT>" ) <EOL> fd = urllib2 . urlopen ( '<STR_LIT>' ) <EOL> got1 = fd . read ( ) <EOL> fd . close ( ) <EOL> expect ( got1 ) . to . equal ( b'<STR_LIT>' ) </s>
