<s> """<STR_LIT>""" <EOL> import __builtin__ <EOL> import os <EOL> import sys <EOL> import tempfile <EOL> import traceback <EOL> import unittest <EOL> from urllib2 import urlopen <EOL> from cellprofiler . modules . tests import example_images_directory , maybe_download_sbs , maybe_download_fly <EOL> def import_all_but_wx ( name , <EOL> globals = __builtin__ . globals ( ) , <EOL> locals = __builtin__ . locals ( ) , <EOL> fromlist = [ ] , level = - <NUM_LIT:1> , <EOL> default_import = __builtin__ . __import__ ) : <EOL> if name == "<STR_LIT>" or name . startswith ( "<STR_LIT>" ) : <EOL> raise ImportError ( "<STR_LIT>" ) <EOL> return default_import ( name , globals , locals , fromlist , level ) <EOL> @ unittest . skipIf ( sys . platform . startswith ( '<STR_LIT>' ) , "<STR_LIT>" ) <EOL> class TestNoWX ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> from cellprofiler . preferences import set_headless , set_temporary_directory <EOL> set_headless ( ) <EOL> set_temporary_directory ( tempfile . gettempdir ( ) ) <EOL> self . old_import = __builtin__ . __import__ <EOL> __builtin__ . __import__ = import_all_but_wx <EOL> def tearDown ( self ) : <EOL> __builtin__ . __import__ = self . old_import <EOL> def example_dir ( self ) : <EOL> return example_images_directory ( ) <EOL> def test_01_01_can_import ( self ) : <EOL> import os <EOL> self . assertTrue ( hasattr ( os , "<STR_LIT>" ) ) <EOL> def test_01_02_throws_on_wx_import ( self ) : <EOL> def import_wx ( ) : <EOL> import wx <EOL> self . assertRaises ( ImportError , import_wx ) <EOL> def test_01_03_import_modules ( self ) : <EOL> '''<STR_LIT>''' <EOL> import cellprofiler . modules <EOL> fly_url = "<STR_LIT>" <EOL> def test_01_05_load_pipeline ( self ) : <EOL> import cellprofiler . pipeline as cpp <EOL> import os <EOL> def callback ( caller , event ) : <EOL> self . assertFalse ( isinstance ( event , cpp . LoadExceptionEvent ) ) <EOL> pipeline = cpp . Pipeline ( ) <EOL> pipeline . add_listener ( callback ) <EOL> try : <EOL> fd = urlopen ( self . fly_url ) <EOL> except IOError , e : <EOL> def bad_url ( e = e ) : <EOL> raise e <EOL> unittest . expectedFailure ( bad_url ) ( ) <EOL> pipeline . load ( fd ) <EOL> fd . close ( ) </s>
