测试这样的代码的最佳方法是什么(下面的代码明显失败,而每次在不同的块中创建对象时):
def get_session(db_name, verbose, test): """Returns current DB session from SQLAlchemy pool. >>> get_session('Mmusc20090126', False, True)""" if test: engine = create_engine('sqlite:///:memory:', echo=verbose) log_load.debug('DB in RAM.') else: engine = create_engine('sqlite:///' + 'DB/' + db_name + '.db', echo=verbose) log_load.debug('DB stored in file: %s' % 'DB/' + db_name + '.db') # Create TABLES: Structures, Interactions, Interactors, PDB_UniProt, UniProtSeq meta.create_all(engine) Session = sessionmaker(bind=engine) session = Session() return session
DNS.. 8
我想你想使用省略号,像这样:
>>> get_session('Mmusc20090126', False, True) #doctest: +ELLIPSIS
有关详细信息,请参见此处
我想你想使用省略号,像这样:
>>> get_session('Mmusc20090126', False, True) #doctest: +ELLIPSIS
有关详细信息,请参见此处