python类drop_all()的实例源码

conftest.py 文件源码 项目:arch-security-tracker 作者: archlinux 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def run_scoped(app, db, client, request):
    with app.app_context():
        connection = db.engine.connect()
        transaction = connection.begin()

        options = dict(bind=connection, binds={})
        session = db.create_scoped_session(options=options)

        db.session = session
        db.create_all()

        with client:
            yield

        db.drop_all()
        transaction.rollback()
        connection.close()
        session.remove()
basecase.py 文件源码 项目:mybookshelf2 作者: izderadicka 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def setUp(self):
        db.drop_all()
        db.create_all()
        connection = db.engine.raw_connection()
        try:
            c = connection.cursor()

            for f in self.INIT_FILES:
                script = open(
                    os.path.join(os.path.dirname(__file__), self.SQL_DIR, f), 'rt', encoding='utf-8-sig').read()
                # print(script)
                res = c.execute(script)
                connection.commit()

        finally:
            pass
            connection.close()
test_back_end.py 文件源码 项目:flask-selenium-webdriver-part-one 作者: mbithenzomo 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def setUp(self):
        """
        Will be called before every test
        """
        db.session.commit()
        db.drop_all()
        db.create_all()

        # create test admin user
        admin = Employee(username="admin", password="admin2016", is_admin=True)

        # create test non-admin user
        employee = Employee(username="test_user", password="test2016")

        # save users to database
        db.session.add(admin)
        db.session.add(employee)
        db.session.commit()
conftest.py 文件源码 项目:arch-security-tracker 作者: archlinux 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def db(request):
    yield flask_db
    flask_db.drop_all()
tasks.py 文件源码 项目:it-jira-bamboohr 作者: saucelabs 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def resetdb(ctx):
    from app import app, db
    with app.app_context():
        db.drop_all()
        db.create_all()
test_client.py 文件源码 项目:circleci-demo-python-flask 作者: CircleCI-Public 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.session.remove()
        db.drop_all()
        self.app_context.pop()
test_api.py 文件源码 项目:circleci-demo-python-flask 作者: CircleCI-Public 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.session.remove()
        db.drop_all()
        self.app_context.pop()
test_basics.py 文件源码 项目:circleci-demo-python-flask 作者: CircleCI-Public 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.session.remove()
        db.drop_all()
        self.app_context.pop()
test_selenium.py 文件源码 项目:circleci-demo-python-flask 作者: CircleCI-Public 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def tearDownClass(cls):
        if cls.client:
            # stop the flask server and the browser
            cls.client.get('http://localhost:5000/shutdown')
            cls.client.close()

            # destroy database
            db.drop_all()
            db.session.remove()

            # remove application context
            cls.app_context.pop()
test_user_model.py 文件源码 项目:circleci-demo-python-flask 作者: CircleCI-Public 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.session.remove()
        db.drop_all()
        self.app_context.pop()
tests.py 文件源码 项目:microflack_messages 作者: miguelgrinberg 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def setUp(self):
        self.ctx = app.app_context()
        self.ctx.push()
        db.drop_all()  # just in case
        db.create_all()
        self.client = app.test_client()
tests.py 文件源码 项目:microflack_messages 作者: miguelgrinberg 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.drop_all()
        self.ctx.pop()
conftest.py 文件源码 项目:do-portal 作者: certeu 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def db(request, app):
    """Create test database tables"""
    _db.drop_all()
    # Create the tables based on the current model
    _db.create_all()

    user = User.create_test_user()
    TestClient.test_user = user
    app.test_client_class = TestClient
    app.response_class = TestResponse

    _db.session.commit()
test_basic.py 文件源码 项目:FMBlog 作者: vc12345679 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.session.remove()
        db.drop_all()
        self.app_context.pop()
test_client.py 文件源码 项目:flasky 作者: RoseOu 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.session.remove()
        db.drop_all()
        self.app_context.pop()
test_api.py 文件源码 项目:flasky 作者: RoseOu 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.session.remove()
        db.drop_all()
        self.app_context.pop()
test_basics.py 文件源码 项目:flasky 作者: RoseOu 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.session.remove()
        db.drop_all()
        self.app_context.pop()
test_selenium.py 文件源码 项目:flasky 作者: RoseOu 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def tearDownClass(cls):
        if cls.client:
            # stop the flask server and the browser
            cls.client.get('http://localhost:5000/shutdown')
            cls.client.close()

            # destroy database
            db.drop_all()
            db.session.remove()

            # remove application context
            cls.app_context.pop()
test_user_model.py 文件源码 项目:flasky 作者: RoseOu 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.session.remove()
        db.drop_all()
        self.app_context.pop()
test_basics.py 文件源码 项目:GWMMS 作者: lvhuiyang 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.session.remove()
        db.drop_all()
        self.app_context.pop()
manage.py 文件源码 项目:web_develop 作者: dongweiming 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def dropdb():
    if prompt_bool(
            'Are you sure you want to lose all your data'):
        db.drop_all()
base.py 文件源码 项目:bucket_api 作者: jokamjohn 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def tearDown(self):
        """
        Drop the database tables and also remove the session
        :return:
        """
        db.session.remove()
        db.drop_all()
test_basic.py 文件源码 项目:chihu 作者: yelongyu 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.session.remove()
        db.drop_all()   # ??????????????????????????????????...
        self.app_context.pop()
test_user_model.py 文件源码 项目:chihu 作者: yelongyu 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.session.remove()
        db.drop_all()
        self.context.pop()
test_basics.py 文件源码 项目:pyetje 作者: rorlika 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.session.remove()
        db.drop_all()
        self.app_context.pop()
test_client.py 文件源码 项目:smart-iiot 作者: quanpower 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.session.remove()
        db.drop_all()
        self.app_context.pop()
test_api.py 文件源码 项目:smart-iiot 作者: quanpower 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.session.remove()
        db.drop_all()
        self.app_context.pop()
test_basics.py 文件源码 项目:smart-iiot 作者: quanpower 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.session.remove()
        db.drop_all()
        self.app_context.pop()
test_selenium.py 文件源码 项目:smart-iiot 作者: quanpower 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def tearDownClass(cls):
        if cls.client:
            # stop the flask server and the browser
            cls.client.get('http://localhost:5000/shutdown')
            cls.client.quit()
            cls.server_thread.join()

            # destroy database
            db.drop_all()
            db.session.remove()

            # remove application context
            cls.app_context.pop()
test_user_model.py 文件源码 项目:smart-iiot 作者: quanpower 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def tearDown(self):
        db.session.remove()
        db.drop_all()
        self.app_context.pop()


问题


面经


文章

微信
公众号

扫码关注公众号