第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

單元測(cè)試 Pyodbc 數(shù)據(jù)庫(kù)連接

單元測(cè)試 Pyodbc 數(shù)據(jù)庫(kù)連接

梵蒂岡之花 2021-07-30 08:12:49
我寫(xiě)了下面的單元測(cè)試來(lái)測(cè)試連接是否成功建立。import unittestfrom databse_access_pyodbc import *from pyodbc import OperationalErrorclass TestDatabseConnection(unittest.TestCase):    def test_connection_db(self):        try:            db_connection = get_db_connection()        except OperationalError as err:            self.fail(                "get_db_connection() raised pyodbc.OperationalError. " +                "Connection to database failed. Detailed error message: " + err)        self.assertIsNone(db_connection)if __name__ == '__main__':    unittest.main()如果可以建立連接,測(cè)試說(shuō):Ran 1 test in 0.001sOKProcess finished with exit code 0如果無(wú)法建立連接,我將得到以下信息:Traceback (most recent call last):  File "xxx\PyCharm-P\ch-0\182.4505.26\helpers\pycharm\_jb_unittest_runner.py", line 35, in <module>    main(argv=args, module=None, testRunner=unittestpy.TeamcityTestRunner, buffer=not JB_DISABLE_BUFFERING)  File "xxx\Python36\lib\unittest\main.py", line 94, in __init__    self.parseArgs(argv)  File "xxx\Python36\lib\unittest\main.py", line 141, in parseArgs    self.createTests()  File "xxx\Python36\lib\unittest\main.py", line 148, in createTests    self.module)  File "xxx\Python36\lib\unittest\loader.py", line 219, in loadTestsFromNames    suites = [self.loadTestsFromName(name, module) for name in names]  File "xxx\Python36\lib\unittest\loader.py", line 219, in <listcomp>    suites = [self.loadTestsFromName(name, module) for name in names]  File "xxx\Python36\lib\unittest\loader.py", line 153, in loadTestsFromName    module = __import__(module_name)  File "xxx\tests\test_database_access_pyodbc.py", line 2, in <module>    from databse_access_pyodbc import *  File "xxx\databse_access_pyodbc.py", line 40, in <module>    get_db_connection()  File "xxx\databse_access_pyodbc.py", line 36, in get_db_connection    autocommit=True)Process finished with exit code 1Empty test suite.為什么OperationalError測(cè)試用例沒(méi)有捕獲異常,為什么它說(shuō):Empty test suite?
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 205 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)