Jul-28-2021, 03:18 PM
Could do it like this,so with
Then add another parameter in the
I guess also popejose way could work.
super()
inherit all the methods and properties from its parent.Then add another parameter in the
__init__()
function.I guess also popejose way could work.
import re import sys import bs4 as bs4 inputURL = sys.argv[1] inputConfig = sys.argv[2] version = sys.argv[3] print(len(sys.argv)) if len(sys.argv) > 4: typeOfTest = sys.argv[4] class Client: def __init__(self, URL, Config, Version): self.Url = URL self.config = Config self.version = Version def perform_test(self): # subprocess.call(['java','-version']) if len(sys.argv) > 4: subprocess.call( ['java', '-jar', 'XXX.jar', '-url', self.Url, '-config', self.config, '-specVersion', self.version]) else: subprocess.call( ['java', '-jar', 'XXX.jar', '-url', self.Url, '-config', self.config, '-specVersion', self.version, '-test', self.testType]) def read_results(self): pass class TestClient(Client): def __init__(self, URL, Config, Version, TestType): super().__init__(URL, Config, Version) self.testType = TestType if __name__ == "__main__": if len(sys.argv) > 4: client = Client(inputURL, inputConfig, version) else: client = TestClient(inputURL, inputConfig, version, typeOfTest) client.perform_test() client.read_results()