fix: ask folder questions through one reader

The copy question, the card question and the BIOS folder question each
read q, Enter, a listed number or a folder. With no drive listed, the
copy question took "2" as the folder ./2. They share one reader now,
and the y/N questions read only y or yes: "yeah" created folders.
This commit is contained in:
Abdessamad Derraz committed 2026-11-21 06:04:39 +01:00
1 parent 1f215f1732
commit 7b89a558ff
10 files changed
+127 -130

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@
# and Invoke-WebRequest throws on a cut transfer before the hash is read: # and Invoke-WebRequest throws on a cut transfer before the hash is read:
# the site's build rewrites this line there (scripts/sitebootstrap.py). # the site's build rewrites this line there (scripts/sitebootstrap.py).
$mismatchAdvice = "The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that." $mismatchAdvice = "The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
$defaultInstallSha256 = "508ffd2832afe8e14dac09860ea73dcb770874c9683f26f8ea0edddb0f7a469b" $defaultInstallSha256 = "c11a387a05a77fd98ad147971abf8ab12bb3caff592f8c28e894adaf57fefa39"
# The pin above refuses any changed byte: this cap only stops a body that # The pin above refuses any changed byte: this cap only stops a body that
# cannot be the installer (a sign-in portal's page) before it is hashed. # cannot be the installer (a sign-in portal's page) before it is hashed.
$maximumInstallerBytes = 8MB $maximumInstallerBytes = 8MB
+49 -58
View File
@@ -2336,6 +2336,32 @@ def _answer_yes(prompt: str) -> bool:
return _ask(prompt).strip().lower() in ("y", "yes") return _ask(prompt).strip().lower() in ("y", "yes")
def _folder_answer(prompt: str, usage: str, default: bool, numbers: int = 0) -> str | None:
"""A folder question's answer: None for Enter on a default, else the
text typed. q quits as at every other question, a folder named q being
typed ./q: q was a folder created in the current one and filled. Enter
with no default, or a number out of range that names no folder, says
what to type: the question came back with no word."""
while True:
raw = _ask(prompt)
if not raw:
if default:
return None
print(usage)
continue
if raw.lower() == "q":
_quit()
if raw.isdigit() and not 1 <= int(raw) <= numbers and not _is_dir(_typed_folder(raw)):
print(usage)
continue
return raw
def _numbers_hint(count: int) -> str:
"""" or 1 to N" after a question that takes a listed number, N rows."""
return "" if not count else " or 1" if count == 1 else f" or 1 to {count}"
class ReadCounter: class ReadCounter:
"""Files read so far, as event_kind events and on the live line: the """Files read so far, as event_kind events and on the live line: the
program driving the installer gets the count the terminal gets.""" program driving the installer gets the count the terminal gets."""
@@ -14538,15 +14564,14 @@ def _missing_dest(dest: Path, ask: bool, named: str = "named with --dest",
(print if missing > 1 and ask else detail)( (print if missing > 1 and ask else detail)(
f" {shown_path(dest)} does not exist. The nearest folder that does: " f" {shown_path(dest)} does not exist. The nearest folder that does: "
f"{shown_path(nearest)}") f"{shown_path(nearest)}")
if missing > 1 and ask: if missing > 1 and ask and not _answer_yes(
answer = _ask(f" Create {_plural(missing, 'folder')} under {shown_path(nearest)}? [y/N] ") f" Create {_plural(missing, 'folder')} under {shown_path(nearest)}? [y/N] "):
if not answer.strip().lower().startswith("y"): if again:
if again: print(" Not created.")
print(" Not created.") return False
return False print(f" Nothing installed. Check the folder {named}, then run "
print(f" Nothing installed. Check the folder {named}, then run " "the command again.")
"the command again.") sys.exit(2)
sys.exit(2)
return True return True
@@ -14982,23 +15007,18 @@ def card_install_dest(named: str, plat: str, interactive: bool, ask: bool = True
else "Mount the card, then type its top folder.")) else "Mount the card, then type its top folder."))
listed = _list_cards(cards, blank) listed = _list_cards(cards, blank)
while True: while True:
numbers = ("" if not listed else " or 1" if len(listed) == 1 usage = (f" Type a number from 1 to {len(listed)}, a folder, Enter to look "
else f" or 1 to {len(listed)}") "again, or q to quit." if listed else
" Type the card's top folder, Enter to look again, or q to quit.")
# Enter looks again, as the screen's Look again does: a card # Enter looks again, as the screen's Look again does: a card
# inserted after the question was never found. # inserted after the question was never found.
raw = _ask(f"Card root{numbers}, Enter to look again, q to quit: ") raw = _folder_answer(f"Card root{_numbers_hint(len(listed))}, Enter to look again, "
if not raw: "q to quit: ", usage, True, len(listed))
if raw is None:
listed = _list_cards(mounted_cards_of(system, plat), blank_cards_of(system, plat), listed = _list_cards(mounted_cards_of(system, plat), blank_cards_of(system, plat),
f"Still no {system} card is mounted.") f"Still no {system} card is mounted.")
continue continue
if raw.lower() == "q":
_quit()
chosen = raw.isdigit() and 1 <= int(raw) <= len(listed) chosen = raw.isdigit() and 1 <= int(raw) <= len(listed)
if raw.isdigit() and not chosen and not _is_dir(_typed_folder(raw)):
print(f" Type a number from 1 to {len(listed)}, a folder, Enter to look "
"again, or q to quit." if listed else
" Type the card's top folder, Enter to look again, or q to quit.")
continue
root = listed[int(raw) - 1] if chosen else _typed_folder(raw).absolute() root = listed[int(raw) - 1] if chosen else _typed_folder(raw).absolute()
choice = card_choice(system, plat, root) choice = card_choice(system, plat, root)
if choice.refused: if choice.refused:
@@ -15180,22 +15200,16 @@ def _ask_from_folder(files: list[dict] | None = None, bios_path: Path | None = N
print("\nCopy from:") print("\nCopy from:")
for number, mount in enumerate(drives, 1): for number, mount in enumerate(drives, 1):
print(f" {number}) {card_line(mount)}") print(f" {number}) {card_line(mount)}")
numbers = "" if not drives else " or 1" if len(drives) == 1 else f" or 1 to {len(drives)}" count = "" if not drives else "1, " if len(drives) == 1 else f"a number from 1 to {len(drives)}, "
# A number out of range, said as one: "2" was read as the folder ./2.
usage = f" Type {count}a folder, or Enter."
while True: while True:
raw = _ask(f"Folder, old card or ZIP to copy from{numbers} (Enter to go back, " raw = _folder_answer(f"Folder, old card or ZIP to copy from{_numbers_hint(len(drives))} "
"q to quit): ").strip() "(Enter to go back, q to quit): ", usage, True, len(drives))
if not raw: if raw is None:
return return
if raw.lower() == "q":
_quit()
if raw.isdigit() and 1 <= int(raw) <= len(drives): if raw.isdigit() and 1 <= int(raw) <= len(drives):
label = str(drives[int(raw) - 1]) label = str(drives[int(raw) - 1])
elif raw.isdigit() and drives and not _is_dir(_typed_folder(raw)):
# A number out of range, said as one: "2" was read as the folder
# ./2.
count = "1" if len(drives) == 1 else f"a number from 1 to {len(drives)}"
print(f" Type {count}, a folder, or Enter.")
continue
else: else:
label = os.path.normpath(str(_typed_folder(raw).absolute())) label = os.path.normpath(str(_typed_folder(raw).absolute()))
refused = copy_source_refusal(Path(label), bios_path) refused = copy_source_refusal(Path(label), bios_path)
@@ -15399,8 +15413,7 @@ def ask_platform_folder(os_type: str, plat: str, ask: bool = True,
unproven = "" if shared else unproven_words() unproven = "" if shared else unproven_words()
if unproven: if unproven:
print(f" {unproven}") print(f" {unproven}")
numbers = "" if not targets else (" or 1" if len(targets) == 1 numbers = _numbers_hint(len(targets))
else f" or 1 to {len(targets)}")
why = ("" if default is not None or shared why = ("" if default is not None or shared
else " (no default, a folder above could not be opened)" else " (no default, a folder above could not be opened)"
if _default_set_aside(os_type, plat) else " (no default on this system)") if _default_set_aside(os_type, plat) else " (no default on this system)")
@@ -15432,27 +15445,6 @@ def ask_platform_folder(os_type: str, plat: str, ask: bool = True,
return folder return folder
def _folder_answer(prompt: str, usage: str, default: bool, numbers: int = 0) -> str | None:
"""A folder question's answer: None for Enter on a default, else the
text typed. q quits as at every other question, a folder named q being
typed ./q: q was a folder created in the current one and filled. Enter
with no default, or a number out of range that names no folder, says
what to type: the question came back with no word."""
while True:
raw = _ask(prompt)
if not raw:
if default:
return None
print(usage)
continue
if raw.lower() == "q":
_quit()
if raw.isdigit() and not 1 <= int(raw) <= numbers and not _is_dir(_typed_folder(raw)):
print(usage)
continue
return raw
def other_side(os_type: str, plat: str) -> list[tuple[str, Path]]: def other_side(os_type: str, plat: str) -> list[tuple[str, Path]]:
"""(label, folder) of the Windows side's usual folder under WSL, where """(label, folder) of the Windows side's usual folder under WSL, where
the one offered first is this Linux's: a Windows RetroArch outside the the one offered first is this Linux's: a Windows RetroArch outside the
@@ -17607,9 +17599,8 @@ def finish_app(
continue continue
if not interactive or args.yes or LOCAL.offline: if not interactive or args.yes or LOCAL.offline:
continue continue
answer = _ask(f"\nPut RetroBIOS on this {card.system} card, to check and update " if _answer_yes(f"\nPut RetroBIOS on this {card.system} card, to check and "
"its BIOS files from the console later? [y/N] ") "update its BIOS files from the console later? [y/N] "):
if answer.lower() in ("y", "yes"):
chosen.append(card) chosen.append(card)
failed = False failed = False
for card in chosen: for card in chosen:
+1 -1
View File
@@ -23,7 +23,7 @@ DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/ins
# curl or wget stop on a cut transfer before the hash is read: the site's # curl or wget stop on a cut transfer before the hash is read: the site's
# build rewrites this line there (scripts/sitebootstrap.py). # build rewrites this line there (scripts/sitebootstrap.py).
MISMATCH_ADVICE="The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that." MISMATCH_ADVICE="The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
DEFAULT_INSTALL_SHA256="508ffd2832afe8e14dac09860ea73dcb770874c9683f26f8ea0edddb0f7a469b" DEFAULT_INSTALL_SHA256="c11a387a05a77fd98ad147971abf8ab12bb3caff592f8c28e894adaf57fefa39"
# The pin above refuses any changed byte: this cap only stops a body that # The pin above refuses any changed byte: this cap only stops a body that
# cannot be the installer (a sign-in portal's page) before it is hashed. # cannot be the installer (a sign-in portal's page) before it is hashed.
MAX_INSTALLER_BYTES=8388608 MAX_INSTALLER_BYTES=8388608
+8 -8
View File
@@ -27,8 +27,8 @@
{ {
"dest": "roms/ports/retrobios/install.py", "dest": "roms/ports/retrobios/install.py",
"repo_path": "install.py", "repo_path": "install.py",
"size": 1450474, "size": 1450086,
"sha256": "508ffd2832afe8e14dac09860ea73dcb770874c9683f26f8ea0edddb0f7a469b", "sha256": "c11a387a05a77fd98ad147971abf8ab12bb3caff592f8c28e894adaf57fefa39",
"executable": false "executable": false
}, },
{ {
@@ -71,8 +71,8 @@
"muos": { "muos": {
"archive": { "archive": {
"dest": "ARCHIVE/RetroBIOS.muxapp", "dest": "ARCHIVE/RetroBIOS.muxapp",
"size": 1504099, "size": 1503711,
"sha256": "a968c9ea40f3abb96913e9c816b44a43431c60c8ce23bafefc715c1767259ff8" "sha256": "c489888589339375e3c62dec4bad0a5a36ab4c8a33c21725b15344099129e709"
}, },
"members": [ "members": [
{ {
@@ -92,8 +92,8 @@
{ {
"name": "RetroBIOS/install.py", "name": "RetroBIOS/install.py",
"repo_path": "install.py", "repo_path": "install.py",
"size": 1450474, "size": 1450086,
"sha256": "508ffd2832afe8e14dac09860ea73dcb770874c9683f26f8ea0edddb0f7a469b", "sha256": "c11a387a05a77fd98ad147971abf8ab12bb3caff592f8c28e894adaf57fefa39",
"executable": false "executable": false
}, },
{ {
@@ -166,8 +166,8 @@
{ {
"dest": ".config/modules/retrobios/install.py", "dest": ".config/modules/retrobios/install.py",
"repo_path": "install.py", "repo_path": "install.py",
"size": 1450474, "size": 1450086,
"sha256": "508ffd2832afe8e14dac09860ea73dcb770874c9683f26f8ea0edddb0f7a469b", "sha256": "c11a387a05a77fd98ad147971abf8ab12bb3caff592f8c28e894adaf57fefa39",
"executable": false "executable": false
}, },
{ {
+27 -1
View File
@@ -9,7 +9,7 @@ from pathlib import Path
from typing import Any, TextIO from typing import Any, TextIO
from installer.events import EVENTS, EVENT_PROGRESS_INTERVAL from installer.events import EVENTS, EVENT_PROGRESS_INTERVAL
from installer.host_fs import _host_path from installer.host_fs import _host_path, _is_dir
from installer.terminal import TUI_MIN_COLS, Terminal, terminal_size from installer.terminal import TUI_MIN_COLS, Terminal, terminal_size
from installer.text import _split_word, cell_width, format_duration, format_size from installer.text import _split_word, cell_width, format_duration, format_size
@@ -275,6 +275,32 @@ def _answer_yes(prompt: str) -> bool:
return _ask(prompt).strip().lower() in ("y", "yes") return _ask(prompt).strip().lower() in ("y", "yes")
def _folder_answer(prompt: str, usage: str, default: bool, numbers: int = 0) -> str | None:
"""A folder question's answer: None for Enter on a default, else the
text typed. q quits as at every other question, a folder named q being
typed ./q: q was a folder created in the current one and filled. Enter
with no default, or a number out of range that names no folder, says
what to type: the question came back with no word."""
while True:
raw = _ask(prompt)
if not raw:
if default:
return None
print(usage)
continue
if raw.lower() == "q":
_quit()
if raw.isdigit() and not 1 <= int(raw) <= numbers and not _is_dir(_typed_folder(raw)):
print(usage)
continue
return raw
def _numbers_hint(count: int) -> str:
"""" or 1 to N" after a question that takes a listed number, N rows."""
return "" if not count else " or 1" if count == 1 else f" or 1 to {count}"
class ReadCounter: class ReadCounter:
"""Files read so far, as event_kind events and on the live line: the """Files read so far, as event_kind events and on the live line: the
program driving the installer gets the count the terminal gets.""" program driving the installer gets the count the terminal gets."""
+15 -21
View File
@@ -23,7 +23,7 @@ from installer.cards import (
share_doubt, share_doubt,
share_drive, share_drive,
) )
from installer.console import _ask, _quit, _typed_folder, detail from installer.console import _answer_yes, _folder_answer, _numbers_hint, _typed_folder, detail
from installer.detect_os import _DETECTED_OS, card_title, detect_os, detected_os, os_conflict from installer.detect_os import _DETECTED_OS, card_title, detect_os, detected_os, os_conflict
from installer.embedded import CARD_MARKER, CARD_PLATFORMS, _EMBEDDED_RULES, _a, _built_on from installer.embedded import CARD_MARKER, CARD_PLATFORMS, _EMBEDDED_RULES, _a, _built_on
from installer.events import EVENTS from installer.events import EVENTS
@@ -95,15 +95,14 @@ def _missing_dest(dest: Path, ask: bool, named: str = "named with --dest",
(print if missing > 1 and ask else detail)( (print if missing > 1 and ask else detail)(
f" {shown_path(dest)} does not exist. The nearest folder that does: " f" {shown_path(dest)} does not exist. The nearest folder that does: "
f"{shown_path(nearest)}") f"{shown_path(nearest)}")
if missing > 1 and ask: if missing > 1 and ask and not _answer_yes(
answer = _ask(f" Create {_plural(missing, 'folder')} under {shown_path(nearest)}? [y/N] ") f" Create {_plural(missing, 'folder')} under {shown_path(nearest)}? [y/N] "):
if not answer.strip().lower().startswith("y"): if again:
if again: print(" Not created.")
print(" Not created.") return False
return False print(f" Nothing installed. Check the folder {named}, then run "
print(f" Nothing installed. Check the folder {named}, then run " "the command again.")
"the command again.") sys.exit(2)
sys.exit(2)
return True return True
@@ -539,23 +538,18 @@ def card_install_dest(named: str, plat: str, interactive: bool, ask: bool = True
else "Mount the card, then type its top folder.")) else "Mount the card, then type its top folder."))
listed = _list_cards(cards, blank) listed = _list_cards(cards, blank)
while True: while True:
numbers = ("" if not listed else " or 1" if len(listed) == 1 usage = (f" Type a number from 1 to {len(listed)}, a folder, Enter to look "
else f" or 1 to {len(listed)}") "again, or q to quit." if listed else
" Type the card's top folder, Enter to look again, or q to quit.")
# Enter looks again, as the screen's Look again does: a card # Enter looks again, as the screen's Look again does: a card
# inserted after the question was never found. # inserted after the question was never found.
raw = _ask(f"Card root{numbers}, Enter to look again, q to quit: ") raw = _folder_answer(f"Card root{_numbers_hint(len(listed))}, Enter to look again, "
if not raw: "q to quit: ", usage, True, len(listed))
if raw is None:
listed = _list_cards(mounted_cards_of(system, plat), blank_cards_of(system, plat), listed = _list_cards(mounted_cards_of(system, plat), blank_cards_of(system, plat),
f"Still no {system} card is mounted.") f"Still no {system} card is mounted.")
continue continue
if raw.lower() == "q":
_quit()
chosen = raw.isdigit() and 1 <= int(raw) <= len(listed) chosen = raw.isdigit() and 1 <= int(raw) <= len(listed)
if raw.isdigit() and not chosen and not _is_dir(_typed_folder(raw)):
print(f" Type a number from 1 to {len(listed)}, a folder, Enter to look "
"again, or q to quit." if listed else
" Type the card's top folder, Enter to look again, or q to quit.")
continue
root = listed[int(raw) - 1] if chosen else _typed_folder(raw).absolute() root = listed[int(raw) - 1] if chosen else _typed_folder(raw).absolute()
choice = card_choice(system, plat, root) choice = card_choice(system, plat, root)
if choice.refused: if choice.refused:
+3 -4
View File
@@ -18,7 +18,7 @@ from pathlib import Path, PurePosixPath
from typing import NamedTuple from typing import NamedTuple
from installer.cards import card_system from installer.cards import card_system
from installer.console import _ask from installer.console import _answer_yes
from installer.events import EVENTS from installer.events import EVENTS
from installer.host_fs import NOT_WRITABLE, _write_refused from installer.host_fs import NOT_WRITABLE, _write_refused
from installer.local_check import _sha256_file from installer.local_check import _sha256_file
@@ -393,9 +393,8 @@ def finish_app(
continue continue
if not interactive or args.yes or LOCAL.offline: if not interactive or args.yes or LOCAL.offline:
continue continue
answer = _ask(f"\nPut RetroBIOS on this {card.system} card, to check and update " if _answer_yes(f"\nPut RetroBIOS on this {card.system} card, to check and "
"its BIOS files from the console later? [y/N] ") "update its BIOS files from the console later? [y/N] "):
if answer.lower() in ("y", "yes"):
chosen.append(card) chosen.append(card)
failed = False failed = False
for card in chosen: for card in chosen:
+8 -36
View File
@@ -15,7 +15,7 @@ from installer.cards import (
setup_bios_folder, setup_bios_folder,
share_doubt, share_doubt,
) )
from installer.console import _ask, _quit, _typed_folder, fold_line from installer.console import _ask, _folder_answer, _numbers_hint, _quit, _typed_folder, fold_line
from installer.destination import ( from installer.destination import (
_last_name, _last_name,
_missing_dest, _missing_dest,
@@ -49,22 +49,16 @@ def _ask_from_folder(files: list[dict] | None = None, bios_path: Path | None = N
print("\nCopy from:") print("\nCopy from:")
for number, mount in enumerate(drives, 1): for number, mount in enumerate(drives, 1):
print(f" {number}) {card_line(mount)}") print(f" {number}) {card_line(mount)}")
numbers = "" if not drives else " or 1" if len(drives) == 1 else f" or 1 to {len(drives)}" count = "" if not drives else "1, " if len(drives) == 1 else f"a number from 1 to {len(drives)}, "
# A number out of range, said as one: "2" was read as the folder ./2.
usage = f" Type {count}a folder, or Enter."
while True: while True:
raw = _ask(f"Folder, old card or ZIP to copy from{numbers} (Enter to go back, " raw = _folder_answer(f"Folder, old card or ZIP to copy from{_numbers_hint(len(drives))} "
"q to quit): ").strip() "(Enter to go back, q to quit): ", usage, True, len(drives))
if not raw: if raw is None:
return return
if raw.lower() == "q":
_quit()
if raw.isdigit() and 1 <= int(raw) <= len(drives): if raw.isdigit() and 1 <= int(raw) <= len(drives):
label = str(drives[int(raw) - 1]) label = str(drives[int(raw) - 1])
elif raw.isdigit() and drives and not _is_dir(_typed_folder(raw)):
# A number out of range, said as one: "2" was read as the folder
# ./2.
count = "1" if len(drives) == 1 else f"a number from 1 to {len(drives)}"
print(f" Type {count}, a folder, or Enter.")
continue
else: else:
label = os.path.normpath(str(_typed_folder(raw).absolute())) label = os.path.normpath(str(_typed_folder(raw).absolute()))
refused = copy_source_refusal(Path(label), bios_path) refused = copy_source_refusal(Path(label), bios_path)
@@ -268,8 +262,7 @@ def ask_platform_folder(os_type: str, plat: str, ask: bool = True,
unproven = "" if shared else unproven_words() unproven = "" if shared else unproven_words()
if unproven: if unproven:
print(f" {unproven}") print(f" {unproven}")
numbers = "" if not targets else (" or 1" if len(targets) == 1 numbers = _numbers_hint(len(targets))
else f" or 1 to {len(targets)}")
why = ("" if default is not None or shared why = ("" if default is not None or shared
else " (no default, a folder above could not be opened)" else " (no default, a folder above could not be opened)"
if _default_set_aside(os_type, plat) else " (no default on this system)") if _default_set_aside(os_type, plat) else " (no default on this system)")
@@ -301,27 +294,6 @@ def ask_platform_folder(os_type: str, plat: str, ask: bool = True,
return folder return folder
def _folder_answer(prompt: str, usage: str, default: bool, numbers: int = 0) -> str | None:
"""A folder question's answer: None for Enter on a default, else the
text typed. q quits as at every other question, a folder named q being
typed ./q: q was a folder created in the current one and filled. Enter
with no default, or a number out of range that names no folder, says
what to type: the question came back with no word."""
while True:
raw = _ask(prompt)
if not raw:
if default:
return None
print(usage)
continue
if raw.lower() == "q":
_quit()
if raw.isdigit() and not 1 <= int(raw) <= numbers and not _is_dir(_typed_folder(raw)):
print(usage)
continue
return raw
def other_side(os_type: str, plat: str) -> list[tuple[str, Path]]: def other_side(os_type: str, plat: str) -> list[tuple[str, Path]]:
"""(label, folder) of the Windows side's usual folder under WSL, where """(label, folder) of the Windows side's usual folder under WSL, where
the one offered first is this Linux's: a Windows RetroArch outside the the one offered first is this Linux's: a Windows RetroArch outside the
+6
View File
@@ -577,6 +577,12 @@ class AMissingDestIsSaid(unittest.TestCase):
self.assertFalse((root / "retroarh").exists()) self.assertFalse((root / "retroarh").exists())
self.assertEqual(self._call(dest, True, "y")[1], None) self.assertEqual(self._call(dest, True, "y")[1], None)
def test_only_y_or_yes_creates_the_folders(self):
# A default-no question read "yeah" as yes, as no other one does.
root = Path(_tempdir(self))
self.assertEqual(self._call(root / "a" / "b", True, "yeah")[1], 2)
self.assertFalse((root / "a").exists())
def test_one_missing_level_or_no_terminal_is_said_not_asked(self): def test_one_missing_level_or_no_terminal_is_said_not_asked(self):
root = Path(_tempdir(self)) root = Path(_tempdir(self))
# A "no" that was asked would stop the run with 2. Said with # A "no" that was asked would stop the run with 2. Said with
+9
View File
@@ -8385,6 +8385,15 @@ class LineModeAndScreenDecideAlike(_LineModeFindings, _OutsideTextFindings,
self.assertIn("Type 1, a folder, or Enter.", out.getvalue()) self.assertIn("Type 1, a folder, or Enter.", out.getvalue())
self.assertNotIn("does not exist", out.getvalue()) self.assertNotIn("does not exist", out.getvalue())
def test_a_number_with_no_drive_listed_is_said_as_one(self):
# With no drive listed, "2" was read as the folder ./2.
with mock.patch.object(install, "_mounted_cards", return_value=[]), \
mock.patch.object(install, "_ask", side_effect=["2", ""]), \
contextlib.redirect_stdout(io.StringIO()) as out:
install._ask_from_folder([], self.here)
self.assertIn("Type a folder, or Enter.", out.getvalue())
self.assertNotIn("does not exist", out.getvalue())
def test_the_copy_line_names_the_folder_it_copies_from(self): def test_the_copy_line_names_the_folder_it_copies_from(self):
payload = b"gba" payload = b"gba"
files = [self.entry("gba_bios.bin", payload, ["nintendo-gba"])] files = [self.entry("gba_bios.bin", payload, ["nintendo-gba"])]