conftest.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:netcrawl 作者: Wyko 项目源码 文件源码
def inventory_db():
    """Sets up a test inventory database and returns the
    database name"""

    config.parse_config()

    fake = Faker()
    dbname= '_'.join(['fakedb',
                   fake.word(),
                   fake.word(),
                   fake.word(),
                  ])

    config.cc.inventory.name = dbname

    # Create the database
    db= io_sql.sql_database()
    db.create_database(dbname)
    assert db.database_exists(dbname)
    del(db)

    print('Inventroy_db: ', dbname)

    # Pass the database to the test functions
    yield

    print('Done with inventory_db: ', dbname)

    # Delete the database after use
    db= io_sql.sql_database()
    db.delete_database(dbname)
    assert not db.database_exists(dbname)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号