How to use assert_version method in avocado

Best Python code snippet using avocado_python

test_utils_vcs_git.py

Source:test_utils_vcs_git.py Github

copy

Full Screen

...102 revision = sha1(uuid.uuid4().bytes).hexdigest()103 with pytest.raises(PoetrySimpleConsoleException) as e:104 Git.clone(url=source_url, revision=revision)105 assert f"Failed to clone {source_url} at '{revision}'" in str(e.value)106def assert_version(repo: Repo, expected_revision: str) -> None:107 version = PyProjectTOML(108 path=Path(repo.path).joinpath("pyproject.toml")109 ).poetry_config["version"]110 revision = Git.get_revision(repo=repo)111 assert revision == expected_revision112 assert revision in REVISION_TO_VERSION_MAP113 assert version == REVISION_TO_VERSION_MAP[revision]114def test_git_clone_when_branch_is_ref(source_url: str) -> None:115 with Git.clone(url=source_url, branch="refs/heads/0.1") as repo:116 assert_version(repo, BRANCH_TO_REVISION_MAP["0.1"])117@pytest.mark.parametrize("branch", [*BRANCH_TO_REVISION_MAP.keys()])118def test_git_clone_branch(119 source_url: str, remote_refs: FetchPackResult, branch: str120) -> None:121 with Git.clone(url=source_url, branch=branch) as repo:122 assert_version(repo, BRANCH_TO_REVISION_MAP[branch])123@pytest.mark.parametrize("tag", [*TAG_TO_REVISION_MAP.keys()])124def test_git_clone_tag(source_url: str, remote_refs: FetchPackResult, tag: str) -> None:125 with Git.clone(url=source_url, tag=tag) as repo:126 assert_version(repo, TAG_TO_REVISION_MAP[tag])127def test_git_clone_multiple_times(128 source_url: str, remote_refs: FetchPackResult129) -> None:130 for revision in REVISION_TO_VERSION_MAP:131 with Git.clone(url=source_url, revision=revision) as repo:132 assert_version(repo, revision)133def test_git_clone_revision_is_branch(134 source_url: str, remote_refs: FetchPackResult135) -> None:136 with Git.clone(url=source_url, revision="0.1") as repo:137 assert_version(repo, BRANCH_TO_REVISION_MAP["0.1"])138def test_git_clone_revision_is_ref(139 source_url: str, remote_refs: FetchPackResult140) -> None:141 with Git.clone(url=source_url, revision="refs/heads/0.1") as repo:142 assert_version(repo, BRANCH_TO_REVISION_MAP["0.1"])143@pytest.mark.parametrize(144 ("revision", "expected_revision"),145 [146 ("0.1", BRANCH_TO_REVISION_MAP["0.1"]),147 ("v0.1.0", TAG_TO_REVISION_MAP["v0.1.0"]),148 *zip(REVISION_TO_VERSION_MAP, REVISION_TO_VERSION_MAP),149 ],150)151def test_git_clone_revision_is_tag(152 source_url: str, remote_refs: FetchPackResult, revision: str, expected_revision: str153) -> None:154 with Git.clone(url=source_url, revision=revision) as repo:155 assert_version(repo, expected_revision)156def test_git_clone_clones_submodules(source_url: str) -> None:157 with Git.clone(url=source_url) as repo:158 submodule_package_directory = (159 Path(repo.path) / "submodules" / "sample-namespace-packages"160 )161 assert submodule_package_directory.exists()162 assert submodule_package_directory.joinpath("README.md").exists()163 assert len(list(submodule_package_directory.glob("*"))) > 1164def test_system_git_fallback_on_http_401(165 mocker: MockerFixture,166 source_url: str,167) -> None:168 spy = mocker.spy(Git, "_clone_legacy")169 mocker.patch.object(Git, "_clone", side_effect=HTTPUnauthorized(None, None))170 with Git.clone(url=source_url, branch="0.1") as repo:171 path = Path(repo.path)172 assert_version(repo, BRANCH_TO_REVISION_MAP["0.1"])173 spy.assert_called_with(174 url="https://github.com/python-poetry/test-fixture-vcs-repository.git",175 target=path,176 refspec=GitRefSpec(branch="0.1", revision=None, tag=None, ref=b"HEAD"),177 )178 spy.assert_called_once()179GIT_USERNAME = os.environ.get("POETRY_TEST_INTEGRATION_GIT_USERNAME")180GIT_PASSWORD = os.environ.get("POETRY_TEST_INTEGRATION_GIT_PASSWORD")181HTTP_AUTH_CREDENTIALS_AVAILABLE = not (GIT_USERNAME and GIT_PASSWORD)182@pytest.mark.skipif(183 HTTP_AUTH_CREDENTIALS_AVAILABLE,184 reason="HTTP authentication credentials not available",185)186def test_configured_repository_http_auth(187 mocker: MockerFixture, source_url: str, config: Config188) -> None:189 from poetry.vcs.git import backend190 spy_clone_legacy = mocker.spy(Git, "_clone_legacy")191 spy_get_transport_and_path = mocker.spy(backend, "get_transport_and_path")192 config.merge(193 {194 "repositories": {"git-repo": {"url": source_url}},195 "http-basic": {196 "git-repo": {197 "username": GIT_USERNAME,198 "password": GIT_PASSWORD,199 }200 },201 }202 )203 dummy_git_config = ConfigFile()204 mocker.patch(205 "poetry.vcs.git.backend.Repo.get_config_stack",206 return_value=dummy_git_config,207 )208 mocker.patch(209 "poetry.vcs.git.backend.get_default_authenticator",210 return_value=Authenticator(config=config),211 )212 with Git.clone(url=source_url, branch="0.1") as repo:213 assert_version(repo, BRANCH_TO_REVISION_MAP["0.1"])214 spy_clone_legacy.assert_not_called()215 spy_get_transport_and_path.assert_called_with(216 location=source_url,217 config=dummy_git_config,218 username=GIT_USERNAME,219 password=GIT_PASSWORD,220 )221 spy_get_transport_and_path.assert_called_once()222def test_username_password_parameter_is_not_passed_to_dulwich(223 mocker: MockerFixture, source_url: str, config: Config224) -> None:225 from poetry.vcs.git import backend226 spy_clone = mocker.spy(Git, "_clone")227 spy_get_transport_and_path = mocker.spy(backend, "get_transport_and_path")228 dummy_git_config = ConfigFile()229 mocker.patch(230 "poetry.vcs.git.backend.Repo.get_config_stack",231 return_value=dummy_git_config,232 )233 with Git.clone(url=source_url, branch="0.1") as repo:234 assert_version(repo, BRANCH_TO_REVISION_MAP["0.1"])235 spy_clone.assert_called_once()236 spy_get_transport_and_path.assert_called_with(237 location=source_url,238 config=dummy_git_config,239 )240 spy_get_transport_and_path.assert_called_once()241def test_system_git_called_when_configured(242 mocker: MockerFixture, source_url: str, use_system_git_client: None243) -> None:244 spy_legacy = mocker.spy(Git, "_clone_legacy")245 spy = mocker.spy(Git, "_clone")246 with Git.clone(url=source_url, branch="0.1") as repo:247 path = Path(repo.path)248 assert_version(repo, BRANCH_TO_REVISION_MAP["0.1"])249 spy.assert_not_called()250 spy_legacy.assert_called_once()251 spy_legacy.assert_called_with(252 url=source_url,253 target=path,254 refspec=GitRefSpec(branch="0.1", revision=None, tag=None, ref=b"HEAD"),...

Full Screen

Full Screen

test_main.py

Source:test_main.py Github

copy

Full Screen

...34 process = subprocess.Popen(args=args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)35 output, _ = process.communicate()36 assert expected_returncode == process.returncode37 return output.decode("utf8")38def assert_version(39 args, # type: List[str]40 expected_version, # type: str41):42 # type: (...) -> None43 output = get_output(args=args + ["--version"])44 assert expected_version == output.strip()45# N.B.: Conscript depends on setuptools for Python <= 3.5 for pkg_resources.iter_entry_points and46# that dependency introduces two easy_install console scripts.47EXPECTED_PROGRAMS = sorted(48 ["foo", "bar"]49 + (["easy_install", "easy_install-3.8"] if sys.version_info[:2] <= (3, 5) else [])50)51OPTIONS_HEADER = "optional arguments" if sys.version_info[:2] < (3, 10) else "options"52def test_conscript(foo_bar_conscript):53 # type: (str) -> Any54 assert_version(args=[foo_bar_conscript, "foo"], expected_version=FOO_VERSION)55 assert_version(args=[foo_bar_conscript, "bar"], expected_version=BAR_VERSION)56 assert (57 dedent(58 """\59 usage: {argv0} [-h] [-V]60 The foo program.61 {options_header}:62 -h, --help show this help message and exit63 -V, --version show program's version number and exit64 """65 ).format(options_header=OPTIONS_HEADER, argv0=os.path.basename(foo_bar_conscript))66 == get_output(args=[foo_bar_conscript, "foo", "-h"])67 )68 assert (69 "usage: {argv0} [-h] [PROGRAM]\n"70 "{argv0}: error: argument PROGRAM: invalid choice: 'baz' (choose from {programs})\n"71 ).format(72 argv0=os.path.basename(foo_bar_conscript),73 programs=", ".join("'{}'".format(program) for program in EXPECTED_PROGRAMS),74 ) == get_output(75 args=[foo_bar_conscript, "baz"], expected_returncode=276 )77def test_busybox(foo_bar_conscript):78 # type: (str) -> Any79 basedir = os.path.dirname(foo_bar_conscript)80 foo_symlink = os.path.join(basedir, "foo")81 os.symlink(foo_bar_conscript, foo_symlink)82 assert_version(args=[foo_symlink], expected_version=FOO_VERSION)83 bar_symlink = os.path.join(basedir, "bar")84 os.symlink(foo_bar_conscript, bar_symlink)85 assert_version(args=[bar_symlink], expected_version=BAR_VERSION)86 non_program_symlink = os.path.join(basedir, "baz")87 os.symlink(foo_bar_conscript, non_program_symlink)88 # N.B.: We insert a string of '*' and later replace these with spaces to work around `dedent`89 # stripping away significant whitespace indentation performed by the help formatter.90 assert (91 dedent(92 """\93 usage: baz [-h] [PROGRAM]94 A baz busy box.95 positional arguments:96 PROGRAM The program to execute.97 **************98 The following programs are available:99 + {programs}...

Full Screen

Full Screen

version.py

Source:version.py Github

copy

Full Screen

2# pylint: disable=redefined-outer-name3from buildstream.testing.runcli import cli # pylint: disable=unused-import4# For utils.get_bst_version()5from buildstream import utils6def assert_version(cli_version_output):7 major, minor = utils.get_bst_version()8 expected_start = "{}.{}".format(major, minor)9 if not cli_version_output.startswith(expected_start):10 raise AssertionError(11 "Version output expected to begin with '{}',".format(expected_start)12 + " output was: {}".format(cli_version_output)13 )14def test_version(cli):15 result = cli.run(args=["--version"])16 result.assert_success()...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful