<s> from __future__ import print_function <EOL> import os <EOL> import sys <EOL> from nose . tools import ok_ <EOL> from linot import interfaces <EOL> def create_dummy_interface ( file_name , interface_name = '<STR_LIT>' , server = True ) : <EOL> path = os . path . dirname ( interfaces . __file__ ) <EOL> with open ( os . path . join ( path , file_name ) , '<STR_LIT>' ) as f : <EOL> print ( '<STR_LIT>' , file = f ) <EOL> print ( '<STR_LIT>' , file = f ) <EOL> print ( "<STR_LIT>" . format ( interface_name ) , file = f ) <EOL> print ( '<STR_LIT>' . format ( server ) , file = f ) <EOL> f . flush ( ) <EOL> class TestIntrefaces : <EOL> def test_import_only_ends_with_interface ( self ) : <EOL> path = os . path . dirname ( interfaces . __file__ ) <EOL> with open ( os . path . join ( path , '<STR_LIT>' ) , '<STR_LIT>' ) as f : <EOL> print ( '<STR_LIT>' , file = f ) <EOL> print ( '<STR_LIT>' , file = f ) <EOL> f . flush ( ) <EOL> reload ( interfaces ) <EOL> ok_ ( '<STR_LIT>' not in sys . modules ) <EOL> try : <EOL> os . remove ( os . path . join ( path , '<STR_LIT>' ) ) <EOL> os . remove ( os . path . join ( path , '<STR_LIT>' ) ) <EOL> except OSError : <EOL> pass <EOL> create_dummy_interface ( file_name = '<STR_LIT>' ) <EOL> loaded = False <EOL> try : <EOL> reload ( interfaces ) <EOL> except ValueError : <EOL> loaded = True <EOL> os . remove ( os . path . join ( path , '<STR_LIT>' ) ) <EOL> os . remove ( os . path . join ( path , '<STR_LIT>' ) ) <EOL> if '<STR_LIT>' in sys . modules : <EOL> loaded = True <EOL> ok_ ( loaded ) <EOL> def test_name_conflict ( self ) : <EOL> path = os . path . dirname ( interfaces . __file__ ) <EOL> create_dummy_interface ( file_name = '<STR_LIT>' , <EOL> interface_name = '<STR_LIT:test>' ) <EOL> error = False <EOL> try : <EOL> reload ( interfaces ) <EOL> except NameError : <EOL> error = True <EOL> os . remove ( os . path . join ( path , '<STR_LIT>' ) ) <EOL> os . remove ( os . path . join ( path , '<STR_LIT>' ) ) <EOL> ok_ ( error ) <EOL> reload ( interfaces ) </s>
