Best Python code snippet using robotframework-androidlibrary_python
conftest.py
Source:conftest.py
...47 raise TypeError("Tried {} times, can't find an open port".format(count))48@pytest.fixture49def port():50 return os.environ["FLASK_PORT"]51def start_testserver():52 port = get_port()53 os.environ["FLASK_APP"] = "coretestserver"54 os.environ["FLASK_PORT"] = str(port)55 cmd = "flask run -p {}".format(port)56 if os.name == 'nt': #On windows, subprocess creation works without being in the shell57 child_process = subprocess.Popen(cmd, env=dict(os.environ))58 else:59 #On linux, have to set shell=True60 child_process = subprocess.Popen(cmd, shell=True, preexec_fn=os.setsid, env=dict(os.environ))61 count = 562 for _ in range(count):63 if not is_port_available(port):64 return child_process65 time.sleep(1)66 raise ValueError("Didn't start!")67def terminate_testserver(process):68 if os.name == 'nt':69 process.kill()70 else:71 os.killpg(os.getpgid(process.pid), signal.SIGTERM) # Send the signal to all the process groups72@pytest.fixture(autouse=True, scope="package")73def testserver():74 """Start the Autorest testserver."""75 server = start_testserver()76 yield77 terminate_testserver(server)78# Ignore collection of async tests for Python 279collect_ignore_glob = []80if sys.version_info < (3, 5):81 collect_ignore_glob.append("*_async.py")82@pytest.fixture83def client(port):84 return AsyncTestRestClient(port)85import sys86# Ignore collection of async tests for Python 287collect_ignore = []88if sys.version_info < (3, 5):89 collect_ignore.append("async_tests")
cases.py
Source:cases.py
...5 """A test case that runs our built-in server in the background."""6 @classmethod7 def setUpClass(cls):8 assert settings.SERVER_ADDRESS[0] == 'built-in'9 cls._httpd = start_testserver(settings.SERVER_ADDRESS[1])10 @classmethod11 def tearDownClass(cls):12 cls._httpd.shutdown()...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!