tests.test_bar_plugin module¶
- tests.test_bar_plugin.test_check_mpm_missing_binary()[source]¶
A probe whose binary does not exist reports the error rather than raising.
- tests.test_bar_plugin.test_ranked_mpm_orders_candidates(monkeypatch)[source]¶
Candidates rank on runnability, freshness and version only.
Their other fields play no part: two failed probes carry exceptions, which do not compare, and a runnable probe with no version sits beside one with a version.
- tests.test_bar_plugin.test_check_mpm_keeps_the_release_suffix()[source]¶
Both readings of one string: the tuple compares, the release is verbatim.
Spawned through the running interpreter rather than a shell, so the probe is the same on Windows.
check_mpmappends its own –no-color –version, which the script ignores.
- tests.test_bar_plugin.test_search_mpm_stops_at_home(monkeypatch, tmp_path)[source]¶
The venv walk stops at Home.
A lockfile sitting in a shared parent above it is then never mistaken for the plugin’s own project.
- tests.test_bar_plugin.test_mpm_cli_ignores_the_spawn_directory(tmp_path)[source]¶
A menu action imports the installed
mpm, wherever it is spawned from.-mprepends the working directory tosys.path, so an action started from a source checkout would import that tree, with the dependencies the installed version pinned.
- tests.test_bar_plugin.test_search_mpm_resolves_a_symlinked_plugin(monkeypatch, tmp_path)[source]¶
The venv walk follows the symlink both hosts are installed through.
A bar app imports this file from its own plugin folder, so an unresolved
__file__walks that folder and finds nothing, leaving the plugin to drive whichever othermpmthe system answers with.
- tests.test_bar_plugin.test_print_honors_a_color_opt_out_off_the_main_thread(monkeypatch, capsys, fake_pool)[source]¶
An explicit
--no-colorstrips the plugin output wherever it is rendered.Only the automatic color state is forced on (see
test_plugin_output_keeps_ansi). The opt-out comes from the color the invocation published for every thread, so it holds on a worker thread too, where the thread-local command context is absent.
- tests.test_bar_plugin.test_renderer_version_diff_colors_by_appearance(monkeypatch, align_columns, os_appearance, present, absent)[source]¶
Package lines carry the version-diff colors with
ansi=true.The colors match the appearance. The prefix gray is constant and non-package lines stay free of escape codes.
- tests.test_bar_plugin.test_elide_versions(old, new, expected)[source]¶
A capped pair stays within the cap, and stays distinguishable.
- tests.test_bar_plugin.test_elide_versions_keeps_the_diff_boundary()[source]¶
The
…lands where the gray prefix hands over to the colored suffix.The elision and
diff_versions()then agree on one split point.
- tests.test_bar_plugin.test_renderer_caps_version_cells(monkeypatch, swiftbar)[source]¶
An over-long version is elided in the menu line.
SwiftBar alone gets the tooltip holding what was dropped.
- tests.test_bar_plugin.test_renderer_version_cap_is_configurable(monkeypatch, value, capped)[source]¶
VAR_MAX_VERSION_WIDTHoverrides the cap.A width leaving no room for the ellipsis turns it off, and a value that is not a number falls back to the default.
- tests.test_bar_plugin.test_renderer_table_alignment_survives_ansi(monkeypatch)[source]¶
Column alignment is computed on visible widths, not raw string lengths.
- tests.test_bar_plugin.test_renderer_elides_long_payload_versions(monkeypatch)[source]¶
A version pair past the cap is elided, as the payload’s own type.
Regression test for the
TypeErrorthat took the whole menu down on any package whose versions ran pastMAX_VERSION_WIDTH:mpm outdatedfills this payload withTokenizedStringversions, which answerlen()but cannot be sliced, and elision slices.
- tests.test_bar_plugin.test_renderer_sanitizes_error_lines(monkeypatch)[source]¶
ANSI codes from a manager’s output are stripped from error lines.
Error lines are marked
ansi=false, which would render the codes as raw text.
- tests.test_bar_plugin.test_renderer_section_header(monkeypatch, is_swiftbar, group_by_manager, align_columns, outdated, expected)[source]¶
The section header carries a count badge and a toggle on SwiftBar.
The badge is actionable and the toggle an accordion. Everywhere else, the header carries the labelled count.
- tests.test_bar_plugin.test_renderer_hides_when_up_to_date(monkeypatch, hide, errors, renders)[source]¶
An empty rendering is produced only when asked and with nothing to say.
An empty rendering is what makes the host drop the menu bar icon.
- tests.test_bar_plugin.test_plugin_empty_mpm_output(monkeypatch, capsys, hide, reports_error)[source]¶
An
mpmproducing nothing is a failure to report.The exception is a user who asked for the icon to vanish while everything is up to date.
- tests.test_bar_plugin.test_plugin_failure_reads_the_exit_code(monkeypatch, capsys, returncode, stderr, reports_error)[source]¶
A refresh fails on the exit code of
mpm, whatever it wrote to<stderr>.A log line never hides the package list.
- tests.test_bar_plugin.test_plugin_options_reach_every_call(monkeypatch)[source]¶
VAR_MPM_OPTIONSlands between the plugin options and the subcommand.It does so on the sync and outdated calls, keeps its case, and never reaches the version probe.
- tests.test_bar_plugin.test_plugin_shell_env_follows_the_mpm_version(monkeypatch, version, passes)[source]¶
--shell-envreaches the sync and outdated calls of anmpmthat has it.It goes right after the command and ahead of
VAR_MPM_OPTIONS, and never reaches an older one.
- tests.test_bar_plugin.test_renderer_actions_carry_the_options(monkeypatch)[source]¶
The embedded upgrade commands carry the same options.
They read them from the environment the
outdatedcall inherits.
- tests.test_bar_plugin.test_renderer_ties_each_upgrade_to_its_manager(monkeypatch)[source]¶
An upgrade command names its package with a pURL of the section manager.
mpmthen upgrades it without first looking for it in the installed packages.
- tests.test_bar_plugin.test_plugin_version_matches_the_package()[source]¶
The
<xbar.version>header follows the package version.bump-my-version keeps it in lockstep, like the GNOME extension’s
version-name.
The footer names both halves of the install and the CLI behind them.
- tests.test_bar_plugin.test_captures_are_referenced_by_the_docs()[source]¶
Each capture is shown on the plugin’s page, and none is an orphan.
The twin of the GNOME extension’s check, with the same scale rule: a capture shown through an image directive carries the reciprocal of the display scale, or it renders at twice the size of everything else, while a card sizes its image to the card and needs none.
- class tests.test_bar_plugin.TestBarPlugin[source]¶
Bases:
object- common_checklist: ClassVar[list] = [('(🎁↑\\d+|📦✓)( ⚠️\\d+)? \\| dropdown=false$', True), ('-{3,5}$', True), ('(--)?🆙 Upgrade all \\S+ packages? \\| shell=\\S+( param\\d+=\\S+)+ refresh=true terminal=(true|false alternate=true)$', False), ('(--)?.+ \\| font=[Mm]enlo size=12 color=red trim=false ansi=false emojize=false( symbolize=false)?$', False), ('About \\|( .+)?$', True), ('--Meta Package Manager \\((SwiftBar|Xbar) plugin\\) \\S+ \\|( .+)?$', True), ('--mpm (\\S+|not found) \\|( .+)?$', True), ('--[^|]+ \\| font=[Mm]enlo size=12$', True), ('--Documentation \\| href=\\S+( .+)?$', True)]¶
- 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]¶
Every Python shell invocation is configured and fits the plugin.
- pytestmark = [Mark(name='skipif', args=(<extra_platforms.pytest._DeferredCondition object>,), kwargs={'reason': 'Requires macOS'}), Mark(name='integration', args=(), kwargs={})]¶