Best Python code snippet using robotframework-androidlibrary_python
__init__.py
Source:__init__.py
...31 self._url = None32 self._testserver_proc = None33 self._username = None34 self._password = None35 self._calabash_bin_path = self._env_command(['calabash-android.bat',36 'calabash-android'])37 def _sdk_path(self, paths):38 for path in paths:39 complete_path = os.path.abspath(os.path.join(40 self._ANDROID_HOME, path))41 if os.path.exists(complete_path):42 return complete_path43 raise AssertionError("Couldn't find %s binary in %s" % (44 os.path.splitext(os.path.split(complete_path)[1])[0],45 os.path.split(complete_path)[0],))46 def _env_command(self, commands):47 for path in os.environ["PATH"].split(os.pathsep):48 for command in commands:49 exe_file = os.path.join(path, command)50 if os.path.isfile(exe_file):51 return exe_file52 raise AssertionError("Couldn't find binary %s" % os.path.commonprefix(commands))53 def _request(self, method, url, *args, **kwargs):54 if self._username is not None and self._password is not None:55 kwargs['auth'] = (self._username, self._password)56 logging.debug(">> %r %r", args, kwargs)57 response = getattr(requests, method)(url, *args, **kwargs)58 return response59 def set_basic_auth(self, username, password):60 '''...
main.py
Source:main.py
1from os import chdir2from pathlib import Path3from textwrap import dedent4import click5import typer6from ensureconda import ensureconda7from senv.commands import env, package, settings_writer8from senv.pyproject import BuildSystem, PyProject9from senv.utils import auto_confirm_yes, build_yes_option, confirm10class AliasedGroup(click.Group):11 def get_command(self, ctx, cmd_name):12 aliases_map = {13 "c": "config",14 "p": "package",15 "e": "env",16 }17 aliased_cmd_name = aliases_map.get(cmd_name, cmd_name)18 rv = click.Group.get_command(self, ctx, aliased_cmd_name)19 if rv is not None:20 return rv21 return None22def pyproject_callback(23 pyproject_file: Path = typer.Option(24 Path(".") / "pyproject.toml", "-f", "--pyproject-file", exists=True25 )26):27 PyProject.read_toml(pyproject_file)28 chdir(PyProject.get().config_path.parent)29app = typer.Typer(cls=AliasedGroup)30app.add_typer(31 env.app,32 name="env",33 no_args_is_help=True,34 help="{alias 'e'} Create and manage you development virtual environment",35 callback=pyproject_callback,36)37app.add_typer(38 settings_writer.app,39 name="config",40 no_args_is_help=True,41 help="{alias 'c'} Add or remove configuration to pyproject.yaml",42 callback=pyproject_callback,43)44app.add_typer(45 package.app,46 name="package",47 no_args_is_help=True,48 help="{alias 'p'} build or publish your project",49 callback=pyproject_callback,50)51def assert_file_does_not_exists(p: Path):52 if p.exists():53 raise typer.Exit(54 "pyproject.toml already exists on this project. "55 "You can manually add parameters to the senv project."56 "\nMore information in https://jorgegarciairazabal.github.io/senv/pyproject/"57 )58@app.command()59def init(60 pyproject_file: Path = typer.Option(61 Path(".") / "pyproject.toml",62 "-f",63 "--pyproject-file",64 callback=assert_file_does_not_exists,65 ),66 package_name: str = typer.Option(Path(".").resolve().name, prompt=True),67 default_build_system: BuildSystem = typer.Option(BuildSystem.CONDA, prompt=True),68 yes: bool = build_yes_option(),69):70 with auto_confirm_yes(yes):71 # no_pyproject_check()72 conda_exe = ensureconda(no_install=True, micromamba=False, mamba=False)73 if conda_exe is None:74 if confirm("Conda not found, do you want to install it", default=True):75 typer.echo(76 f"Conda installed in {ensureconda(micromamba=False, mamba=False)}"77 )78 init_project_template = dedent(79 """80 [tool.senv]81 name = "{package_name}"82 version = "0.1.0"83 license = "Proprietary"84 build-system = "{build_system}"85 86 # description = "Describe your project"87 # authors = ["MyName <MyName@domanin.com>"]88 # readme = "README.md"89 # homepage = "https://homapage.com"90 91 92 [tool.senv.dependencies]93 # All the direct dependencies you package depend on94 python = ">3.7.0, <3.10.0"95 96 97 [tool.senv.dev-dependencies]98 # Dependencies needed for development (typical examples: pytest, mkdocs, etc.)99 # these dependencies will not be included when publishing the package100 """101 ).strip()102 pyproject_file.write_text(103 init_project_template.format(104 package_name=package_name, build_system=default_build_system.value105 )106 )107# renaming commands for documentation, this will not be used in production108_env_command = typer.main.get_command(env.app)109_env_command.name = "senv env"110env_command = _env_command111_config_command = typer.main.get_command(settings_writer.app)112_config_command.name = "senv config"113config_command = _config_command114_package_command = typer.main.get_command(package.app)115_package_command.name = "senv package"116package_command = _package_command117if __name__ == "__main__":...
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!!