meta_package_manager.tests package#
Submodules#
meta_package_manager.tests.conftest module#
- meta_package_manager.tests.conftest.pytest_addoption(parser)[source]#
Add custom command line options.
Based on Pytest’s documentation examples.
By default, runs non-destructive tests and skips destructive ones.
- meta_package_manager.tests.conftest.solve_destructive_options(config)[source]#
Solve the destructive options to determine which tests to run.
- meta_package_manager.tests.conftest.pytest_collection_modifyitems(config, items)[source]#
Either skip or run destructive tests based on command line options.
- meta_package_manager.tests.conftest.pytest_report_header(config, start_path)[source]#
Display destructive options status in test report header.
- meta_package_manager.tests.conftest.subcmd()[source]#
Fixture used in
test_cli_*.py
files to set the subcommand arguments in all CLI calls.Must returns a string or an iterable of strings. Defaults to
None
, which allows tests relying on this fixture to selectively skip running.
- meta_package_manager.tests.conftest.PACKAGE_IDS = {'apm': 'markdown-pdf', 'apt': 'wget', 'apt-mint': 'exiftool', 'brew': 'meta-package-manager', 'cargo': 'colorous', 'cask': 'pngyu', 'choco': 'ccleaner', 'composer': 'illuminate/contracts', 'dnf': 'usd', 'emerge': 'dev-vcs/git', 'flatpak': 'org.gnome.Dictionary', 'gem': 'markdown', 'mas': '747648890', 'npm': 'raven', 'opkg': 'enigma2-hotplug', 'pacaur': 'manjaro-hello', 'pacman': 'manjaro-hello', 'paru': 'meta-package-manager', 'pip': 'meta-package-manager', 'pipx': 'meta-package-manager', 'pkg': 'dmg2img', 'scoop': '7zip', 'snap': 'standard-notes', 'steamcmd': '740', 'vscode': 'tamasfe.even-better-toml', 'yarn': 'awesome-lint', 'yay': 'meta-package-manager', 'yum': 'usd', 'zypper': 'git'}#
List of existing package IDs to install for each supported package manager.
Only to be used for destructive tests.
- meta_package_manager.tests.conftest.pytest_runtest_teardown(item, nextitem)[source]#
Force the reset, after each subcommand test, of NPM’s cached CLI path.
This hack is applied on macOS only, in which parallel tests are messing up with the location of the system’s NPM binary. This ends up in cryptic test suite failures, as the
npm
CLI is moved around during execution:Clearing the
cli_path
cached property forcesmpm
to re-search thenpm
binary on the system.
meta_package_manager.tests.test_bar_plugin module#
- class meta_package_manager.tests.test_bar_plugin.TestBarPlugin[source]#
Bases:
object
- common_checklist = [('(🎁↑\\d+|📦✓)( ⚠️\\d+)? \\| dropdown=false$', True), ('-{3,5}$', True), ('(--)?🆙 Upgrade all \\S+ packages? \\| shell=\\S+( param\\d+=\\S+)+ refresh=true terminal=(false|true alternate=true)$', True), ('(--)?.+ \\| font=Menlo size=12 color=red trim=false ansi=false emojize=false( symbolize=false)?$', False)]#
- plugin_output_checks(checklist, extra_env=None)[source]#
Run the plugin script and check its output against the checklist.
- test_plugin_shell_invocation(shell_args)[source]#
Test execution of plugin on different shells.
Do not execute the complete search for outdated packages, just stop at searching for the mpm executable and extract its version.
- test_python_shell_invocation(shell_args, python_args)[source]#
Test any Python shell invocation is properly configured and all are compatible with plugin requirements.
- pytestmark = [Mark(name='skipif', args=(True,), kwargs={'reason': 'macOS required'})]#
meta_package_manager.tests.test_cli module#
- class meta_package_manager.tests.test_cli.InspectCLIOutput[source]#
Bases:
object
- static evaluate_signals(mid, stdout, stderr)[source]#
Search in the CLI output for evidence that a manager has been retained.
..tip:
In the implementation, signals should be roughly sorted from most specific to more forgiving.
- check_manager_selection(result, selected=('apt', 'apt-mint', 'brew', 'cargo', 'composer', 'dnf', 'emerge', 'flatpak', 'gem', 'npm', 'opkg', 'pacaur', 'pacman', 'paru', 'pip', 'pipx', 'pkg', 'snap', 'steamcmd', 'vscode', 'yarn', 'yay', 'yum', 'zypper'), reference_set=('apt', 'apt-mint', 'brew', 'cargo', 'composer', 'dnf', 'emerge', 'flatpak', 'gem', 'npm', 'opkg', 'pacaur', 'pacman', 'paru', 'pip', 'pipx', 'pkg', 'snap', 'steamcmd', 'vscode', 'yarn', 'yay', 'yum', 'zypper'), strict_selection_match=True)[source]#
Check that user-selected managers are found in CLI’s output.
To establish that
mpm
CLI is properly selecting managers, we search for signals in CLI logs, by matching regular expressions against<stdout>
and<stderr>
. This strategy close the gap of testing internal code testing and end user experience.Signals are expected to be implemented for each subcommand by the
evaluate_signals()
method.strict_selection_match
check that all selected managers are properly reported in CLI output and none are missing.Caution
At this stage of the CLI execution, the order in which the managers are reported doesn’t matter because:
<stdout>
and<stderr>
gets mangled- `paging is async
<https://github.com/kdeldycke/meta-package-manager/issues/528>`_
- we may introduce `parallel execution of managers in the future
<https://github.com/kdeldycke/meta-package-manager/issues/529>`_
This explain the use of
set()
everywhere in this method.
- class meta_package_manager.tests.test_cli.TestCommonCLI[source]#
Bases:
object
Single tests for CLI behavior shared by all subcommands.
If we have to, we only run the test on a single, non-destructive subcommand (like
mpm installed
ormpm managers
). Not all subcommands are tested.That way we prevent running similar tests which are operating on the same, shared code path. Thus improving overall execution of the test suite.
- class meta_package_manager.tests.test_cli.TestManagerSelection[source]#
Bases:
InspectCLIOutput
Test selection of package managers to use.
Tests are performed here on the
mpm managers
subcommand, as it is a safe read-only operation that is supposed to work on all platforms, whatever the environment.There is not need to test all subcommands, as the selection logic and code path is shared by all of them. See the implementation in
meta_package_manager.pool.ManagerPool.select_managers()
.
- class meta_package_manager.tests.test_cli.CLISubCommandTests[source]#
Bases:
InspectCLIOutput
All these tests runs on each subcommand.
This class doesn’t starts with Test as it is meant to be used as a template, inherited by sub-command specific test cases.
meta_package_manager.tests.test_cli_backup module#
- class meta_package_manager.tests.test_cli_backup.TestBackup[source]#
Bases:
CLISubCommandTests
meta_package_manager.tests.test_cli_cleanup module#
- class meta_package_manager.tests.test_cli_cleanup.TestCleanup[source]#
Bases:
CLISubCommandTests
meta_package_manager.tests.test_cli_install_remove module#
- class meta_package_manager.tests.test_cli_install_remove.TestInstallRemove[source]#
Bases:
CLISubCommandTests
Install and remove operations are siblings and sensible, so we regroup them under the same test suite.
Tip
Where we can, we invoke the
install
subcommand to installmpm
with itself, so we can test externally contributed packaging.
meta_package_manager.tests.test_cli_installed module#
- class meta_package_manager.tests.test_cli_installed.TestInstalled[source]#
Bases:
CLISubCommandTests
,CLITableTests
meta_package_manager.tests.test_cli_managers module#
- class meta_package_manager.tests.test_cli_managers.TestManagers[source]#
Bases:
CLISubCommandTests
,CLITableTests
meta_package_manager.tests.test_cli_outdated module#
- class meta_package_manager.tests.test_cli_outdated.TestOutdated[source]#
Bases:
CLISubCommandTests
,CLITableTests
meta_package_manager.tests.test_cli_restore module#
- meta_package_manager.tests.test_cli_restore.subcmd(create_config)[source]#
Seed common subcommand tests with a dummy file and content to allow the CLI to not fail on required file input.
- class meta_package_manager.tests.test_cli_restore.TestRestore[source]#
Bases:
CLISubCommandTests
- static evaluate_signals(mid, stdout, stderr)[source]#
Search in the CLI output for evidence that a manager has been retained.
..tip:
In the implementation, signals should be roughly sorted from most specific to more forgiving.
- pytestmark = [Mark(name='skip', args=(), kwargs={'reason': 'Generated config file is not isolated from other tests.'})]#
meta_package_manager.tests.test_cli_search module#
- class meta_package_manager.tests.test_cli_search.TestSearch[source]#
Bases:
CLISubCommandTests
,CLITableTests
- static evaluate_signals(mid, stdout, stderr)[source]#
Search in the CLI output for evidence that a manager has been retained.
..tip:
In the implementation, signals should be roughly sorted from most specific to more forgiving.
- test_unicode_search(invoke)[source]#
Check
mpm
is accepting unicode as search query.mas
is the only manager we have that is accepting unicode characters for its package names. We perform a search with it so we can provempm
is supporting it too:► mpm --mas search 钉钉 ╭────────────┬──────┬─────────┬────────────────╮ │ Package ID │ Name │ Manager │ Latest version │ ├────────────┼──────┼─────────┼────────────────┤ │ 1435447041 │ 钉钉 │ mas │ 7.5.0 │ ╰────────────┴──────┴─────────┴────────────────╯
Test originates from #16.
- skip_pip_search(*args, **kwargs) = MarkDecorator(mark=Mark(name='skip', args=(), kwargs={'reason': 'pip search is deprecated'}))#
meta_package_manager.tests.test_cli_sync module#
- class meta_package_manager.tests.test_cli_sync.TestSync[source]#
Bases:
CLISubCommandTests
meta_package_manager.tests.test_cli_upgrade module#
- class meta_package_manager.tests.test_cli_upgrade.TestUpgrade[source]#
Bases:
CLISubCommandTests
Test the system-wide upgrade sub-command.
Danger
All tests here should me marked as destructive unless –dry-run parameter is passed.
meta_package_manager.tests.test_cli_which module#
- class meta_package_manager.tests.test_cli_which.TestWhich[source]#
Bases:
CLISubCommandTests
,CLITableTests
meta_package_manager.tests.test_docs module#
meta_package_manager.tests.test_manager_apt module#
APT-specific tests.
meta_package_manager.tests.test_manager_homebrew module#
Homebrew-specific tests.
- meta_package_manager.tests.test_manager_homebrew.install_cask()[source]#
A fixture to install a Cask from a specific commit.
- class meta_package_manager.tests.test_manager_homebrew.TestCask[source]#
Bases:
object
- pytestmark = [Mark(name='skip', args=(), kwargs={'reason': 'Cask repository structure changed too much to go back in time.'}), Mark(name='skipif', args=(True,), kwargs={'reason': 'macOS required'}), Mark(name='destructive', args=(), kwargs={})]#
meta_package_manager.tests.test_managers module#
- meta_package_manager.tests.test_managers.test_ascii_id(manager)[source]#
All package manager IDs should be short ASCII strings.
- meta_package_manager.tests.test_managers.test_name(manager)[source]#
Check all managers have a name.
- meta_package_manager.tests.test_managers.test_platforms(manager)[source]#
Check platforms is normalized as a frozenset.
- meta_package_manager.tests.test_managers.test_requirement(manager)[source]#
Each manager is required to specify a minimal version or
None
.
- meta_package_manager.tests.test_managers.test_cli_names_type(manager)[source]#
Check the pointed CLI name and path are file-system compatible.
- meta_package_manager.tests.test_managers.test_extra_env_type(manager)[source]#
Check that definitions environment variables as a dict of strings.
- meta_package_manager.tests.test_managers.test_global_args_type(manager)[source]#
Check that definitions returns CLI args as a list of non-empty strings.
- meta_package_manager.tests.test_managers.test_version_cli_options(manager)[source]#
Version CLI options must be a list of non empty strings.
- meta_package_manager.tests.test_managers.test_version_regex(manager)[source]#
Version regex is required.
Check it compiles and match has a version group.
- meta_package_manager.tests.test_managers.collect_props_ref()[source]#
Build the canonical reference from the base class.
We need to parse the AST so we can collect both attributes and naked type annotations.
meta_package_manager.tests.test_platforms module#
meta_package_manager.tests.test_pool module#
- meta_package_manager.tests.test_pool.test_manager_definition_inventory()[source]#
Check all classes implementing a package manager are accounted for in the pool.
- meta_package_manager.tests.test_pool.test_manager_classes_order()[source]#
Check manager classes are ordered by their IDs.
- meta_package_manager.tests.test_pool.test_manager_count()[source]#
Check all implemented package managers are accounted for, and unique.
meta_package_manager.tests.test_specifier module#
meta_package_manager.tests.test_version module#
- meta_package_manager.tests.test_version.reverse_fixtures(table)[source]#
Utility method to reverse a tuple of tuples.