# encoding = utf-8
"""物件導向第一大特徵:封裝
基於python3
"""class
cellphone
:"""
手機類"""
def__init__
(self, cell_phone_number)
: self.cell_phone_number = cell_phone_number
self.battery_percentage =
100def
dial
(self, cell_phone_number)
:print
("calling %s"
% cell_phone_number)
defsend_sms
(self, cell_phone_number, message)
:print
("sending %s to %s"
%(message, cell_phone_number)
)def
start_charge
(self)
:print
("charging..."
)def
stop_charge
(self)
:print
("charge finished"
)if __name__ ==
'__main__'
: p30 = cellphone(
"159******xx"
) p40 = cellphone(
"180******xx"
)print
("p30 手機號是 %s"
% p30.cell_phone_number)
print
("p30 手機還剩餘電量 %d"
% p30.battery_percentage)
p40.battery_percentage =
50print
("p40 手機號是 %s"
% p40.cell_phone_number)
print
("p40 手機還剩餘電量 %d"
% p40.battery_percentage)
p30.dial(p40.cell_phone_number)
p40.send_sms(p30.cell_phone_number,
"give u feedback later"
)
# encoding = utf-8
from oop import cellphone
class
symbianmobilephone
(cellphone)
:"""
塞班手機
"""pass
class
smartmobilephone
(cellphone)
:"""
智慧型手機
"""def__init__
(self, cell_phone_number, os=
"android"):
super()
.__init__(cell_phone_number)
self.os = os
list()
def:
print
(def
:print
("正在刪除應用 %s"
class
fullsmartmobilephone
(smartmobilephone)
:"""
全面屏智慧型手機
"""def__init__
(self, cell_phone_number, screen_size, os=
"android"):
super()
.__init__(cell_phone_number, os)
self.screen_size = screen_size
class
folderscreensmartmobilephone
(smartmobilephone)
:"""
摺疊屏智慧型手機
"""deffold
(self)
:print
("the cellphone is folded"
)def
unfold
(self)
:print
("the cellphone is unfolded"
)
# encoding = utf-8
class
iphone
:"""
iphone基類,具有乙個解鎖功能
"""defunlock
(self, pass_code,
**kwargs)
:print
("解鎖iphone"
)return
true
class
iphone5s
(iphone)
:"""
iphone5s,unlock功能增加了指紋解鎖
"""deffinger_unlock
(self, fingerprint)
:return
true
defunlock
(self, pass_code,
**kwargs)
: fingerprint = kwargs.get(
"fingerprint"
,none
)if self.finger_unlock(fingerprint)
:print
("指紋解鎖成功"
)return
true
else
:return
super()
.unlock(pass_code)
class
iphonex
(iphone)
:"""
iphonex, unlock功能增加刷臉解鎖
"""defface_unlock
(self, face_id)
:return
true
defunlock
(self, pass_code,
**kwargs)
: face_id = kwargs.get(
"face_id"
,none
)if self.face_unlock(face_id)
:print
("通過刷臉解鎖成功"
)return
true
else
:super()
.unlock(pass_code)
from abc import abcmeta, abstractmethod
class
mobilephone
(metaclass=abcmeta)
: @abstractmethod
defunlock
(self, credential)
:pass
class
iphone
(mobilephone)
:def
unlock
(self, credential)
:print
("iphone解鎖"
)class
iphone5s
(mobilephone)
:def
unlock
(self, credential)
:print
("5s解鎖"
)class
iphonex
(mobilephone)
:def
unlock
(self, credential)
:print
("iphonex解鎖"
)def
test_unlock
(phone):if
isinstance
(phone, iphone)
: phone.unlock(
"......"
)else
:print
("傳入的引數必須是mobilephone型別"
)return
false
if __name__ ==
'__main__'
: phone = iphone(
) test_unlock(phone)
自動化測試平台化 v1 0 0 事件資源鎖
在資源設計中,所有的資源從配置檔案中讀出後成為例項儲存,通常情況下資源的名字是唯一的,因此可以通過資源名作為的鎖的關鍵字,然後使用乙個結構體來儲存相應資源的鎖資訊,並使用訊號量來標識鎖狀態 假設執行緒a對該資源進行操作,重置了訊號量,當執行緒b也需要使用該資源並對其進行加鎖的時候,就會因為該資源所對...
自動化測試 web自動化測試
自動化 由機器裝置代替人為完成制定目標的過程 優點 提高工作效率 減少勞動力 產品規格同一標準 批量生產 自動化測試 讓程式代替人為去驗證程式功能的過程,即在預設條件下執行程式系統 流程確定 搭建自動化框架 編寫測試用例,將其轉化為soupui 介面 自動化測試指令碼 執行自動化測試指令碼 輸出執行...
自動化測試平台的探索
只做了基本的幾個控制項,在文字框內輸入要生成的檔案數量,點選生成後在相應的目錄下生成對應的檔案 對應的 也很簡單,就乙個from表單,如下 1 doctype html 2 html lang en 3 head 4 meta charset utf 8 5 title 測試檔案生成頁 生成 sty...