문제

이와 같은 코드를 테스트하는 가장 좋은 방법은 무엇입니까 (아래는 분명히 실패하지만 객체가 매번 다른 블록에서 생성되는 동안 실패) :

def get_session(db_name, verbose, test):
"""Returns current DB session from SQLAlchemy pool.

>>> get_session('Mmusc20090126', False, True)
<sqlalchemy.orm.session.Session object at 0xfb5ff0>

"""
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
도움이 되었습니까?

해결책

나는 당신이 다음과 같이 Ellipsis를 사용하고 싶다고 생각합니다.

>>> get_session('Mmusc20090126', False, True) #doctest: +ELLIPSIS
<sqlalchemy.orm.session.Session object at 0x...>

보다 여기 더 많은 정보를 위해서.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top