자동화 테스트 플랫폼화[v1.0.0][대상용]
20178 단어 자동화된 테스트 플랫폼화
봉인하다
# encoding = utf-8
"""
:
Python3
"""
class CellPhone:
"""
"""
def __init__(self, cell_phone_number):
self.cell_phone_number = cell_phone_number
self.battery_percentage = 100
def dial(self, cell_phone_number):
print("Calling %s" % cell_phone_number)
def send_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("159xxxxxxxx")
P40 = CellPhone("180xxxxxxxx")
print("P30 %s" % P30.cell_phone_number)
print("P30 %d" % P30.battery_percentage)
P40.battery_percentage = 50
print("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
self.app_list = list()
def download_app(self, app_name):
print(" %s" % app_name)
def delete_app(self, app_name):
print(" %s" % app_name)
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):
"""
"""
def fold(self):
print("The CellPhone is folded")
def unfold(self):
print("The CellPhone is unfolded")
다태
# encoding = utf-8
class IPhone:
"""
IPhone ,
"""
def unlock(self, pass_code, **kwargs):
print(" IPhone")
return True
class IPhone5S(IPhone):
"""
IPhone5S,unlock
"""
def finger_unlock(self, fingerprint):
return True
def unlock(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
"""
def face_unlock(self, face_id):
return True
def unlock(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
def unlock(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)