From 2a0496f03c4ffd04786b5954691d870c3c7ace61 Mon Sep 17 00:00:00 2001 From: shai Date: Thu, 7 Mar 2024 17:30:47 +0200 Subject: [PATCH] first attempt with strudel --- .build/allow_all_python_version.py | 2 +- jrnl/__init__.py | 2 +- jrnl/__main__.py | 3 +- jrnl/__version__.py | 2 +- jrnl/config.py | 12 +++- jrnl/editor.py | 6 +- jrnl/encryption/BaseKeyEncryption.py | 2 +- jrnl/encryption/Jrnlv1Encryption.py | 3 +- jrnl/encryption/NoEncryption.py | 2 +- jrnl/encryption/__init__.py | 4 +- jrnl/install.py | 12 +++- jrnl/journals/__init__.py | 2 +- jrnl/keyring.py | 4 +- jrnl/main.py | 7 ++- jrnl/messages/MsgText.py | 2 +- jrnl/messages/__init__.py | 2 +- jrnl/os_compat.py | 2 +- jrnl/output.py | 8 ++- jrnl/path.py | 2 +- jrnl/plugins/__init__.py | 4 +- jrnl/prompt.py | 6 +- jrnl/time.py | 10 +++- jrnl/upgrade.py | 10 +++- tasks.py | 3 +- tests/bdd/test_features.py | 2 +- tests/conftest.py | 10 +++- tests/lib/helpers.py | 6 +- tests/lib/then_steps.py | 25 +++++++- tests/lib/type_builders.py | 2 +- tests/lib/when_steps.py | 3 +- tests/unit/test_color.py | 2 +- tests/unit/test_config_file.py | 2 +- tests/unit/test_controller.py | 2 +- tests/unit/test_editor.py | 90 ++++++++++++++-------------- tests/unit/test_export.py | 2 +- tests/unit/test_install.py | 2 +- tests/unit/test_os_compat.py | 2 +- tests/unit/test_output.py | 2 +- tests/unit/test_override.py | 2 +- tests/unit/test_parse_args.py | 2 +- tests/unit/test_path.py | 2 +- tests/unit/test_time.py | 2 +- 42 files changed, 186 insertions(+), 86 deletions(-) diff --git a/.build/allow_all_python_version.py b/.build/allow_all_python_version.py index 5827709f..d1a61583 100644 --- a/.build/allow_all_python_version.py +++ b/.build/allow_all_python_version.py @@ -5,4 +5,4 @@ pyproject = toml.load("pyproject.toml") pyproject["tool"]["poetry"]["dependencies"]["python"] = "*" with open("pyproject.toml", "w") as toml_file: - toml.dump(pyproject, toml_file) + toml.dump(pyproject, toml_file) \ No newline at end of file diff --git a/jrnl/__init__.py b/jrnl/__init__.py index 6186dc2e..5a5caafa 100644 --- a/jrnl/__init__.py +++ b/jrnl/__init__.py @@ -5,4 +5,4 @@ try: from jrnl.__version__ import __version__ except ImportError: __version__ = "source" -__title__ = "jrnl" +__title__ = "jrnl" \ No newline at end of file diff --git a/jrnl/__main__.py b/jrnl/__main__.py index 085da2a0..16a354d3 100644 --- a/jrnl/__main__.py +++ b/jrnl/__main__.py @@ -6,4 +6,5 @@ import sys from jrnl.main import run if __name__ == "__main__": - sys.exit(run()) + logger.info(f'Condition in body log is: __name__({__name__}) = "__main__"') # STRUDEL_LOG hrxs + sys.exit(run()) \ No newline at end of file diff --git a/jrnl/__version__.py b/jrnl/__version__.py index f75c1f63..84325f5b 100644 --- a/jrnl/__version__.py +++ b/jrnl/__version__.py @@ -1 +1 @@ -__version__ = "v4.1" +__version__ = "v4.1" \ No newline at end of file diff --git a/jrnl/config.py b/jrnl/config.py index b335204b..121822bc 100644 --- a/jrnl/config.py +++ b/jrnl/config.py @@ -103,10 +103,12 @@ def get_default_colors() -> dict[str, Any]: def scope_config(config: dict, journal_name: str) -> dict: if journal_name not in config["journals"]: + logger.info(f'Condition in body log is: journal_name NotIn config["journals"]') # STRUDEL_LOG kwyl return config config = config.copy() journal_conf = config["journals"].get(journal_name) if isinstance(journal_conf, dict): + logger.info(f'Condition in body log is: journal_conf is type: dict') # STRUDEL_LOG cwdp # We can override the default config on a by-journal basis logging.debug( "Updating configuration with specific journal overrides:\n%s", @@ -130,8 +132,10 @@ def verify_config_colors(config: dict) -> bool: for key, color in config["colors"].items(): upper_color = color.upper() if upper_color == "NONE": + logger.info(f'Condition in body log is: upper_color({upper_color}) = "NONE"') # STRUDEL_LOG utcp continue if not getattr(colorama.Fore, upper_color, None): + logger.info(f'Condition in body log is: UnaryOp getattr( colorama.Fore upper_color None)') # STRUDEL_LOG zdgs print_msg( Message( MsgText.InvalidColor, @@ -182,8 +186,10 @@ def update_config( or config['journals'][scope] is just a string pointing to a journal file, or within the scope""" if scope and isinstance(config["journals"][scope], dict): + logger.info(f'Condition in body log is: scope BoolOp isinstance( config["journals"][scope] dict)') # STRUDEL_LOG eyxh config["journals"][scope].update(new_config) elif scope and force_local: # Convert to dict + logger.info(f'Condition in body log is: Both scope AND force_local are True') # STRUDEL_LOG bzob config["journals"][scope] = {"journal": config["journals"][scope]} config["journals"][scope].update(new_config) else: @@ -195,11 +201,14 @@ def get_journal_name(args: argparse.Namespace, config: dict) -> argparse.Namespa # The first arg might be a journal name if args.text: + logger.info(f'Condition in body log is: Attribute "text" of "args" is True') # STRUDEL_LOG leag potential_journal_name = args.text[0] if potential_journal_name[-1] == ":": + logger.info(f'Condition in body log is: potential_journal_name[UnaryOp 1] = ":"') # STRUDEL_LOG cqmv potential_journal_name = potential_journal_name[0:-1] if potential_journal_name in config["journals"]: + logger.info(f'Condition in body log is: potential_journal_name in config["journals"]') # STRUDEL_LOG npkg args.journal_name = potential_journal_name args.text = args.text[1:] @@ -217,6 +226,7 @@ def cmd_requires_valid_journal_name(func: Callable) -> Callable: def validate_journal_name(journal_name: str, config: dict) -> None: if journal_name not in config["journals"]: + logger.info(f'Condition in body log is: journal_name NotIn config["journals"]') # STRUDEL_LOG thla raise JrnlException( Message( MsgText.NoNamedJournal, @@ -226,4 +236,4 @@ def validate_journal_name(journal_name: str, config: dict) -> None: "journals": list_journals(config), }, ), - ) + ) \ No newline at end of file diff --git a/jrnl/editor.py b/jrnl/editor.py index 2226ad1d..78efdabf 100644 --- a/jrnl/editor.py +++ b/jrnl/editor.py @@ -22,6 +22,7 @@ from jrnl.path import get_templates_path def get_text_from_editor(config: dict, template: str = "") -> str: suffix = ".jrnl" if config["template"]: + logger.info(f'Condition in body log is: config["template"]') # STRUDEL_LOG djpb template_filename = Path(config["template"]).name suffix = "-" + template_filename filehandle, tmpfile = tempfile.mkstemp(prefix="jrnl", text=True, suffix=suffix) @@ -29,6 +30,7 @@ def get_text_from_editor(config: dict, template: str = "") -> str: with open(tmpfile, "w", encoding="utf-8") as f: if template: + logger.info(f'Condition in body log is: template') # STRUDEL_LOG ygot f.write(template) try: @@ -47,6 +49,7 @@ def get_text_from_editor(config: dict, template: str = "") -> str: os.remove(tmpfile) if not raw: + logger.info(f'Condition in body log is: (not raw) is True') # STRUDEL_LOG newi raise JrnlException(Message(MsgText.NoTextReceived, MsgStyle.NORMAL)) return raw @@ -80,6 +83,7 @@ def get_text_from_stdin() -> str: def get_template_path(template_path: str, jrnl_template_dir: str) -> str: actual_template_path = os.path.join(jrnl_template_dir, template_path) if not os.path.exists(actual_template_path): + logger.info(f'Condition in body log is: UnaryOp os.path.exists( actual_template_path)') # STRUDEL_LOG rlgy logging.debug( f"Couldn't open {actual_template_path}. " "Treating template path like a local / abs path." @@ -118,4 +122,4 @@ def read_template_file(template_path: str) -> str: "jrnl_template_dir": str(jrnl_template_dir) + os.sep, }, ) - ) + ) \ No newline at end of file diff --git a/jrnl/encryption/BaseKeyEncryption.py b/jrnl/encryption/BaseKeyEncryption.py index f8c20bc9..002bc9a8 100644 --- a/jrnl/encryption/BaseKeyEncryption.py +++ b/jrnl/encryption/BaseKeyEncryption.py @@ -5,4 +5,4 @@ from .BaseEncryption import BaseEncryption class BaseKeyEncryption(BaseEncryption): - pass + pass \ No newline at end of file diff --git a/jrnl/encryption/Jrnlv1Encryption.py b/jrnl/encryption/Jrnlv1Encryption.py index 18a9782b..2cb50e7c 100644 --- a/jrnl/encryption/Jrnlv1Encryption.py +++ b/jrnl/encryption/Jrnlv1Encryption.py @@ -32,6 +32,7 @@ class Jrnlv1Encryption(BasePasswordEncryption): try: plain_padded = decryptor.update(cipher) + decryptor.finalize() if plain_padded[-1] in (" ", 32): + logger.info(f'Condition in body log is: plain_padded[UnaryOp 1] in tuple of length 2.') # STRUDEL_LOG cznx # Ancient versions of jrnl. Do not judge me. return plain_padded.decode(self._encoding).rstrip(" ") else: @@ -39,4 +40,4 @@ class Jrnlv1Encryption(BasePasswordEncryption): plain = unpadder.update(plain_padded) + unpadder.finalize() return plain.decode(self._encoding) except ValueError: - return None + return None \ No newline at end of file diff --git a/jrnl/encryption/NoEncryption.py b/jrnl/encryption/NoEncryption.py index 66fa4f80..5213ae98 100644 --- a/jrnl/encryption/NoEncryption.py +++ b/jrnl/encryption/NoEncryption.py @@ -17,4 +17,4 @@ class NoEncryption(BaseEncryption): def _decrypt(self, text: bytes) -> str: logging.debug("decrypting") - return text.decode(self._encoding) + return text.decode(self._encoding) \ No newline at end of file diff --git a/jrnl/encryption/__init__.py b/jrnl/encryption/__init__.py index afa92edb..2be9482d 100644 --- a/jrnl/encryption/__init__.py +++ b/jrnl/encryption/__init__.py @@ -7,6 +7,7 @@ from typing import TYPE_CHECKING from typing import Type if TYPE_CHECKING: + logger.info(f'Condition in body log is: TYPE_CHECKING') # STRUDEL_LOG rxap from .BaseEncryption import BaseEncryption @@ -29,8 +30,9 @@ def determine_encryption_method(config: str | bool) -> Type["BaseEncryption"]: key = config if isinstance(config, str): + logger.info(f'Condition in body log is: config is type: str') # STRUDEL_LOG ifbj key = config.lower() my_class = ENCRYPTION_METHODS[key] - return getattr(import_module(f"jrnl.encryption.{my_class}"), my_class) + return getattr(import_module(f"jrnl.encryption.{my_class}"), my_class) \ No newline at end of file diff --git a/jrnl/install.py b/jrnl/install.py index 4033c33c..99fccdda 100644 --- a/jrnl/install.py +++ b/jrnl/install.py @@ -40,14 +40,17 @@ def upgrade_config(config_data: dict, alt_config_path: str | None = None) -> Non default_config = get_default_config() missing_keys = set(default_config).difference(config_data) if missing_keys: + logger.info(f'Condition in body log is: missing_keys') # STRUDEL_LOG mipm for key in missing_keys: config_data[key] = default_config[key] different_version = config_data["version"] != __version__ if different_version: + logger.info(f'Condition in body log is: different_version') # STRUDEL_LOG odzs config_data["version"] = __version__ if missing_keys or different_version: + logger.info(f'Condition in body log is: Either missing_keys OR different_version is True') # STRUDEL_LOG xugd save_config(config_data, alt_config_path) config_path = alt_config_path if alt_config_path else get_config_path() print_msg( @@ -68,6 +71,7 @@ def find_default_config() -> str: def find_alt_config(alt_config: str) -> str: if not os.path.exists(alt_config): + logger.info(f'Condition in body log is: UnaryOp os.path.exists( alt_config)') # STRUDEL_LOG ruqd raise JrnlException( Message( MsgText.AltConfigNotFound, MsgStyle.ERROR, {"config_file": alt_config} @@ -88,10 +92,12 @@ def load_or_install_jrnl(alt_config_path: str) -> dict: ) if os.path.exists(config_path): + logger.info(f'Condition in body log is: os.path.exists( config_path)') # STRUDEL_LOG mosl logging.debug("Reading configuration from file %s", config_path) config = load_config(config_path) if config is None: + logger.info(f'Condition in body log is: config({config}) Is None') # STRUDEL_LOG sply raise JrnlException( Message( MsgText.CantParseConfigFile, @@ -103,6 +109,7 @@ def load_or_install_jrnl(alt_config_path: str) -> dict: ) if is_old_version(config_path): + logger.info(f'Condition in body log is: is_old_version( config_path)') # STRUDEL_LOG xcqp from jrnl import upgrade upgrade.upgrade_jrnl(config_path) @@ -145,12 +152,14 @@ def install() -> dict: # Encrypt it? encrypt = yesno(Message(MsgText.EncryptJournalQuestion), default=False) if encrypt: + logger.info(f'Condition in body log is: encrypt') # STRUDEL_LOG afpw default_config["encrypt"] = True print_msg(Message(MsgText.JournalEncrypted, MsgStyle.NORMAL)) # Use colors? use_colors = yesno(Message(MsgText.UseColorsQuestion), default=True) if use_colors: + logger.info(f'Condition in body log is: use_colors') # STRUDEL_LOG edic default_config["colors"] = get_default_colors() save_config(default_config) @@ -169,6 +178,7 @@ def install() -> dict: def _initialize_autocomplete() -> None: # readline is not included in Windows Active Python and perhaps some other distss if sys.modules.get("readline"): + logger.info(f'Condition in body log is: sys.modules.get( "readline")') # STRUDEL_LOG dusn import readline readline.set_completer_delims(" \t\n;") @@ -180,4 +190,4 @@ def _autocomplete_path(text: str, state: int) -> list[str | None]: expansions = glob.glob(expand_path(text) + "*") expansions = [e + "/" if os.path.isdir(e) else e for e in expansions] expansions.append(None) - return expansions[state] + return expansions[state] \ No newline at end of file diff --git a/jrnl/journals/__init__.py b/jrnl/journals/__init__.py index eb3dc44f..5513f78a 100644 --- a/jrnl/journals/__init__.py +++ b/jrnl/journals/__init__.py @@ -2,4 +2,4 @@ from .DayOneJournal import DayOne from .Entry import Entry from .FolderJournal import Folder from .Journal import Journal -from .Journal import open_journal +from .Journal import open_journal \ No newline at end of file diff --git a/jrnl/keyring.py b/jrnl/keyring.py index 42396a7a..1cab9e5f 100644 --- a/jrnl/keyring.py +++ b/jrnl/keyring.py @@ -14,6 +14,7 @@ def get_keyring_password(journal_name: str = "default") -> str | None: return keyring.get_password("jrnl", journal_name) except keyring.errors.KeyringError as e: if not isinstance(e, keyring.errors.NoKeyringError): + logger.info(f'Condition in body log is: UnaryOp isinstance( e keyring.errors.NoKeyringError)') # STRUDEL_LOG ladx print_msg(Message(MsgText.KeyringRetrievalFailure, MsgStyle.ERROR)) return None @@ -23,7 +24,8 @@ def set_keyring_password(password: str, journal_name: str = "default") -> None: return keyring.set_password("jrnl", journal_name, password) except keyring.errors.KeyringError as e: if isinstance(e, keyring.errors.NoKeyringError): + logger.info(f'Condition in body log is: isinstance( e keyring.errors.NoKeyringError)') # STRUDEL_LOG gnnn msg = Message(MsgText.KeyringBackendNotFound, MsgStyle.WARNING) else: msg = Message(MsgText.KeyringRetrievalFailure, MsgStyle.ERROR) - print_msg(msg) + print_msg(msg) \ No newline at end of file diff --git a/jrnl/main.py b/jrnl/main.py index 770690c4..8c462323 100644 --- a/jrnl/main.py +++ b/jrnl/main.py @@ -18,6 +18,7 @@ from jrnl.output import print_msg def configure_logger(debug: bool = False) -> None: if not debug: + logger.info(f'Condition in body log is: (not debug) is True') # STRUDEL_LOG ealt logging.disable() return @@ -35,6 +36,7 @@ def configure_logger(debug: bool = False) -> None: def run(manual_args: list[str] | None = None) -> int: try: if manual_args is None: + logger.info(f'Condition in body log is: manual_args({manual_args}) Is None') # STRUDEL_LOG yrbb manual_args = sys.argv[1:] args = parse_args(manual_args) @@ -63,14 +65,17 @@ def run(manual_args: list[str] | None = None) -> int: debug = False try: if args.debug: # type: ignore + logger.info(f'Condition in body log is: Attribute "debug" of "args" is True') # STRUDEL_LOG ynyg debug = True except NameError: # This should only happen when the exception # happened before the args were parsed if "--debug" in sys.argv: + logger.info(f'Condition in body log is: "--debug" in sys.argv') # STRUDEL_LOG zyck debug = True if debug: + logger.info(f'Condition in body log is: debug') # STRUDEL_LOG ccav from rich.console import Console traceback.print_tb(sys.exc_info()[2]) @@ -85,4 +90,4 @@ def run(manual_args: list[str] | None = None) -> int: ) # This should be the only exit point - return status_code + return status_code \ No newline at end of file diff --git a/jrnl/messages/MsgText.py b/jrnl/messages/MsgText.py index 9361781d..4bc3a023 100644 --- a/jrnl/messages/MsgText.py +++ b/jrnl/messages/MsgText.py @@ -283,4 +283,4 @@ class MsgText(Enum): DeprecatedCommand = """ The command {old_cmd} is deprecated and will be removed from jrnl soon. Please use {new_cmd} instead. - """ + """ \ No newline at end of file diff --git a/jrnl/messages/__init__.py b/jrnl/messages/__init__.py index 5f520c10..938ae25e 100644 --- a/jrnl/messages/__init__.py +++ b/jrnl/messages/__init__.py @@ -7,4 +7,4 @@ from jrnl.messages import MsgText Message = Message.Message MsgStyle = MsgStyle.MsgStyle -MsgText = MsgText.MsgText +MsgText = MsgText.MsgText \ No newline at end of file diff --git a/jrnl/os_compat.py b/jrnl/os_compat.py index 16a689a0..48de434b 100644 --- a/jrnl/os_compat.py +++ b/jrnl/os_compat.py @@ -15,4 +15,4 @@ def on_posix() -> bool: def split_args(args: str) -> list[str]: """Split arguments and add escape characters as appropriate for the OS""" - return shlex.split(args, posix=on_posix()) + return shlex.split(args, posix=on_posix()) \ No newline at end of file diff --git a/jrnl/output.py b/jrnl/output.py index 48487d40..a994f147 100644 --- a/jrnl/output.py +++ b/jrnl/output.py @@ -24,6 +24,7 @@ def deprecated_cmd( ) if callback is not None: + logger.info(f'Condition in body log is: callback IsNot None') # STRUDEL_LOG ojwq callback(**kwargs) @@ -67,8 +68,10 @@ def list_journals(configuration: dict, format: str | None = None) -> str: } if format == "json": + logger.info(f'Condition in body log is: format({format}) = "json"') # STRUDEL_LOG aoms return journal_list_to_json(journal_list) elif format == "yaml": + logger.info(f'Condition in body log is: format({format}) = "yaml"') # STRUDEL_LOG cqep return journal_list_to_yaml(journal_list) else: return journal_list_to_stdout(journal_list) @@ -97,11 +100,13 @@ def print_msgs( m = format_msg_text(msg) if i != len(msgs) - 1: + logger.info(f'Condition in body log is: i != len( msgs) BinOp 1') # STRUDEL_LOG wjax m.append(delimiter) text.append(m) if style.append_space: + logger.info(f'Condition in body log is: Attribute "append_space" of "style" is True') # STRUDEL_LOG ecqs text.append(" ") decorated_text = style.decoration.callback(text, **kwargs) @@ -110,6 +115,7 @@ def print_msgs( console = _get_console(stderr=True) if get_input: + logger.info(f'Condition in body log is: get_input') # STRUDEL_LOG zvxo return str(console.input(prompt=decorated_text, password=hide_input)) console.print(decorated_text, new_line_start=style.prepend_newline) @@ -139,4 +145,4 @@ def wrap_with_ansi_colors(text: str, width: int) -> str: console = Console(width=width, force_terminal=True) with console.capture() as capture: console.print(richtext, sep="", end="") - return capture.get() + return capture.get() \ No newline at end of file diff --git a/jrnl/path.py b/jrnl/path.py index 4361cf97..cb14cd19 100644 --- a/jrnl/path.py +++ b/jrnl/path.py @@ -69,4 +69,4 @@ def get_config_path() -> str: config_directory_path = get_config_directory() except JrnlException: return os.path.join(home_dir(), DEFAULT_CONFIG_NAME) - return os.path.join(config_directory_path, DEFAULT_CONFIG_NAME) + return os.path.join(config_directory_path, DEFAULT_CONFIG_NAME) \ No newline at end of file diff --git a/jrnl/plugins/__init__.py b/jrnl/plugins/__init__.py index 993d8686..69915c3a 100644 --- a/jrnl/plugins/__init__.py +++ b/jrnl/plugins/__init__.py @@ -37,6 +37,7 @@ IMPORT_FORMATS = sorted(__importer_types.keys()) def get_exporter(format: str) -> Type[TextExporter] | None: for exporter in __exporters: if hasattr(exporter, "names") and format in exporter.names: + logger.info(f'Condition in body log is: hasattr( exporter "names") BoolOp format in exporter.names') # STRUDEL_LOG vxeb return exporter return None @@ -44,5 +45,6 @@ def get_exporter(format: str) -> Type[TextExporter] | None: def get_importer(format: str) -> Type[JRNLImporter] | None: for importer in __importers: if hasattr(importer, "names") and format in importer.names: + logger.info(f'Condition in body log is: hasattr( importer "names") BoolOp format in importer.names') # STRUDEL_LOG tkzr return importer - return None + return None \ No newline at end of file diff --git a/jrnl/prompt.py b/jrnl/prompt.py index e4071480..ce3b8a79 100644 --- a/jrnl/prompt.py +++ b/jrnl/prompt.py @@ -24,17 +24,20 @@ def create_password(journal_name: str) -> str: ) if not pw: + logger.info(f'Condition in body log is: (not pw) is True') # STRUDEL_LOG xyiw print_msg(Message(MsgText.PasswordCanNotBeEmpty, MsgStyle.WARNING)) continue elif pw == print_msg( Message(MsgText.PasswordConfirmEntry, MsgStyle.PROMPT), **kwargs ): + logger.info(f'Condition in body log is: pw = print_msg( Message( MsgText.PasswordConfirmEntry MsgStyle.PROMPT))') # STRUDEL_LOG dhhc break print_msg(Message(MsgText.PasswordDidNotMatch, MsgStyle.ERROR)) if yesno(Message(MsgText.PasswordStoreInKeychain), default=True): + logger.info(f'Condition in body log is: yesno( Message( MsgText.PasswordStoreInKeychain))') # STRUDEL_LOG feov from jrnl.keyring import set_keyring_password set_keyring_password(pw, journal_name) @@ -44,6 +47,7 @@ def create_password(journal_name: str) -> str: def prompt_password(first_try: bool = True) -> str: if not first_try: + logger.info(f'Condition in body log is: (not first_try) is True') # STRUDEL_LOG xmea print_msg(Message(MsgText.WrongPasswordTryAgain, MsgStyle.WARNING)) return ( @@ -77,4 +81,4 @@ def yesno(prompt: Message | str, default: bool = True) -> bool: } # Does using `lower()` work in all languages? - return answers.get(str(response).lower().strip(), default) + return answers.get(str(response).lower().strip(), default) \ No newline at end of file diff --git a/jrnl/time.py b/jrnl/time.py index 533ea54d..5b091eba 100644 --- a/jrnl/time.py +++ b/jrnl/time.py @@ -27,13 +27,16 @@ def parse( ) -> datetime.datetime | None: """Parses a string containing a fuzzy date and returns a datetime.datetime object""" if not date_str: + logger.info(f'Condition in body log is: (not date_str) is True') # STRUDEL_LOG tedc return None elif isinstance(date_str, datetime.datetime): + logger.info(f'Condition in body log is: isinstance( date_str datetime.datetime)') # STRUDEL_LOG idcg return date_str # Don't try to parse anything with 6 or fewer characters and was parsed from the # existing journal. It's probably a markdown footnote if len(date_str) <= 6 and bracketed: + logger.info(f'Condition in body log is: len( date_str) <= 6 BoolOp bracketed') # STRUDEL_LOG nujw return None default_date = DEFAULT_FUTURE if inclusive else DEFAULT_PAST @@ -49,6 +52,7 @@ def parse( date = dateparse(date_str, default=default_date) if date.year == FAKE_YEAR: + logger.info(f'Condition in body log is: date.year = FAKE_YEAR') # STRUDEL_LOG axfv date = datetime.datetime( datetime.datetime.now().year, date.timetuple()[1:6] ) @@ -59,6 +63,7 @@ def parse( date = date.timetuple() except Exception as e: if e.args[0] == "day is out of range for month": + logger.info(f'Condition in body log is: e.args[0] = "day is out of range for month"') # STRUDEL_LOG janj y, m, d, H, M, S = default_date.timetuple()[:6] default_date = datetime.datetime(y, m, d - 1, H, M, S) else: @@ -68,6 +73,7 @@ def parse( hasDate = parse_context.hasDate if not hasDate and not hasTime: + logger.info(f'Condition in body log is: (not hasDate) is True BoolOp (not hasTime) is True') # STRUDEL_LOG onqx try: # Try and parse this as a single year year = int(date_str) return datetime.datetime(year, 1, 1) @@ -77,6 +83,7 @@ def parse( return None if hasDate and not hasTime: + logger.info(f'Condition in body log is: hasDate BoolOp (not hasTime) is True') # STRUDEL_LOG uzyb date = datetime.datetime( # Use the default time *date[:3], hour=23 if inclusive else default_hour or 0, @@ -91,6 +98,7 @@ def parse( # tell it to prefer past dates dt = datetime.datetime.now() - date if dt.days < -28 and not year_present: + logger.info(f'Condition in body log is: dt.days < UnaryOp 28 BoolOp (not year_present) is True') # STRUDEL_LOG eodx date = date.replace(date.year - 1) return date @@ -100,4 +108,4 @@ def is_valid_date(year: int, month: int, day: int) -> bool: datetime.datetime(year, month, day) return True except ValueError: - return False + return False \ No newline at end of file diff --git a/jrnl/upgrade.py b/jrnl/upgrade.py index 1b6e500d..eafb1c46 100644 --- a/jrnl/upgrade.py +++ b/jrnl/upgrade.py @@ -40,6 +40,7 @@ def backup(filename: str, binary: bool = False): print_msg(Message(MsgText.DoesNotExist, MsgStyle.WARNING, {"name": filename})) cont = yesno(f"\nCreate {filename}?", default=False) if not cont: + logger.info(f'Condition in body log is: (not cont) is True') # STRUDEL_LOG vqec raise JrnlException(Message(MsgText.UpgradeAborted, MsgStyle.WARNING)) @@ -62,6 +63,7 @@ def upgrade_jrnl(config_path: str) -> None: for journal_name, journal_conf in config["journals"].items(): if isinstance(journal_conf, dict): + logger.info(f'Condition in body log is: journal_conf is type: dict') # STRUDEL_LOG jdkv path = expand_path(journal_conf.get("journal")) encrypt = journal_conf.get("encrypt") else: @@ -69,14 +71,17 @@ def upgrade_jrnl(config_path: str) -> None: path = expand_path(journal_conf) if os.path.exists(path): + logger.info(f'Condition in body log is: os.path.exists( path)') # STRUDEL_LOG ooxz path = os.path.expanduser(path) else: print_msg(Message(MsgText.DoesNotExist, MsgStyle.ERROR, {"name": path})) continue if encrypt: + logger.info(f'Condition in body log is: encrypt') # STRUDEL_LOG paoq encrypted_journals[journal_name] = path elif os.path.isdir(path): + logger.info(f'Condition in body log is: os.path.isdir( path)') # STRUDEL_LOG rbud other_journals[journal_name] = path else: plain_journals[journal_name] = path @@ -116,6 +121,7 @@ def upgrade_jrnl(config_path: str) -> None: cont = yesno(Message(MsgText.ContinueUpgrade), default=False) if not cont: + logger.info(f'Condition in body log is: (not cont) is True') # STRUDEL_LOG ywxs raise JrnlException(Message(MsgText.UpgradeAborted, MsgStyle.WARNING)) for journal_name, path in encrypted_journals.items(): @@ -166,6 +172,7 @@ def upgrade_jrnl(config_path: str) -> None: failed_journals = [j for j in all_journals if not j.validate_parsing()] if len(failed_journals) > 0: + logger.info(f'Condition in body log is: len( failed_journals) > 0') # STRUDEL_LOG euov raise JrnlException( Message(MsgText.AbortingUpgrade, MsgStyle.WARNING), Message( @@ -195,6 +202,7 @@ def is_old_version(config_path: str) -> bool: def _print_journal_summary(journals: dict, header: Message, pad: int) -> None: if not journals: + logger.info(f'Condition in body log is: (not journals) is True') # STRUDEL_LOG jlxe return msgs = [header] @@ -209,4 +217,4 @@ def _print_journal_summary(journals: dict, header: Message, pad: int) -> None: }, ) ) - print_msgs(msgs) + print_msgs(msgs) \ No newline at end of file diff --git a/tasks.py b/tasks.py index 478f74da..4fb63edf 100644 --- a/tasks.py +++ b/tasks.py @@ -46,6 +46,7 @@ def generate_pa11y_config_from_sitemap(): def output_file(file): if not os.getenv("CI", False): + logger.info(f'Condition in body log is: UnaryOp os.getenv( "CI" False)') # STRUDEL_LOG tafj return print(f"::group::{file}") @@ -53,4 +54,4 @@ def output_file(file): with open(file) as f: print(f.read()) - print("::endgroup::") + print("::endgroup::") \ No newline at end of file diff --git a/tests/bdd/test_features.py b/tests/bdd/test_features.py index 0a994a1a..1185eb69 100644 --- a/tests/bdd/test_features.py +++ b/tests/bdd/test_features.py @@ -23,4 +23,4 @@ scenarios("features/star.feature") scenarios("features/tag.feature") scenarios("features/template.feature") scenarios("features/upgrade.feature") -scenarios("features/write.feature") +scenarios("features/write.feature") \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py index c64820c2..ae91eb5f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -18,14 +18,18 @@ pytest_plugins = [ def pytest_bdd_apply_tag(tag, function): # skip markers if tag == "skip_win": + logger.info(f'Condition in body log is: tag({tag}) = "skip_win"') # STRUDEL_LOG ured marker = mark.skipif(on_windows(), reason="Skip test on Windows") elif tag == "skip_posix": + logger.info(f'Condition in body log is: tag({tag}) = "skip_posix"') # STRUDEL_LOG ddbs marker = mark.skipif(on_posix(), reason="Skip test on Mac/Linux") # only on OS markers elif tag == "on_win": + logger.info(f'Condition in body log is: tag({tag}) = "on_win"') # STRUDEL_LOG zjqp marker = mark.skipif(not on_windows(), reason="Skip test not on Windows") elif tag == "on_posix": + logger.info(f'Condition in body log is: tag({tag}) = "on_posix"') # STRUDEL_LOG zgja marker = mark.skipif(not on_posix(), reason="Skip test not on Mac/Linux") else: # Fall back to pytest-bdd's default behavior @@ -42,13 +46,17 @@ def pytest_runtest_setup(item): on_nix = on_posix() if "skip_win" in markers and on_win: + logger.info(f'Condition in body log is: "skip_win" in markers BoolOp on_win') # STRUDEL_LOG iabq skip("Skip test on Windows") if "skip_posix" in markers and on_nix: + logger.info(f'Condition in body log is: "skip_posix" in markers BoolOp on_nix') # STRUDEL_LOG asee skip("Skip test on Mac/Linux") if "on_win" in markers and not on_win: + logger.info(f'Condition in body log is: "on_win" in markers BoolOp (not on_win) is True') # STRUDEL_LOG gknf skip("Skip test not on Windows") if "on_posix" in markers and not on_nix: - skip("Skip test not on Mac/Linux") + logger.info(f'Condition in body log is: "on_posix" in markers BoolOp (not on_nix) is True') # STRUDEL_LOG ojpo + skip("Skip test not on Mac/Linux") \ No newline at end of file diff --git a/tests/lib/helpers.py b/tests/lib/helpers.py index a6ec5cb9..1438bf92 100644 --- a/tests/lib/helpers.py +++ b/tests/lib/helpers.py @@ -7,11 +7,13 @@ import os def does_directory_contain_files(file_list, directory_path): if not os.path.isdir(directory_path): + logger.info(f'Condition in body log is: UnaryOp os.path.isdir( directory_path)') # STRUDEL_LOG iyeb return False for file in file_list.split("\n"): fullpath = directory_path + "/" + file if not os.path.isfile(fullpath): + logger.info(f'Condition in body log is: UnaryOp os.path.isfile( fullpath)') # STRUDEL_LOG iemx return False return True @@ -20,6 +22,7 @@ def does_directory_contain_files(file_list, directory_path): def does_directory_contain_n_files(directory_path, number): count = 0 if not os.path.isdir(directory_path): + logger.info(f'Condition in body log is: UnaryOp os.path.isdir( directory_path)') # STRUDEL_LOG ykwn return False files = [ @@ -51,6 +54,7 @@ def get_nested_val(dictionary, path, *default): return functools.reduce(lambda x, y: x[y], path.split("."), dictionary) except KeyError: if default: + logger.info(f'Condition in body log is: default') # STRUDEL_LOG ltbz return default[0] raise @@ -73,4 +77,4 @@ def get_fixture(request, name, default=None): try: return request.getfixturevalue(name) except LookupError: - return default + return default \ No newline at end of file diff --git a/tests/lib/then_steps.py b/tests/lib/then_steps.py index 84461bc3..350ac89d 100644 --- a/tests/lib/then_steps.py +++ b/tests/lib/then_steps.py @@ -61,14 +61,17 @@ def output_should_contain(expected, which_output_stream, cli_run, it_should): assert expected if which_output_stream is None: + logger.info(f'Condition in body log is: which_output_stream({which_output_stream}) Is None') # STRUDEL_LOG ivav assert ((expected in cli_run["stdout"]) == it_should) or ( (expected in cli_run["stderr"]) == it_should ), output_str elif which_output_stream == "standard": + logger.info(f'Condition in body log is: which_output_stream({which_output_stream}) = "standard"') # STRUDEL_LOG zlhq assert (expected in cli_run["stdout"]) == it_should, output_str elif which_output_stream == "error": + logger.info(f'Condition in body log is: which_output_stream({which_output_stream}) = "error"') # STRUDEL_LOG qlkb assert (expected in cli_run["stderr"]) == it_should, output_str else: @@ -156,12 +159,14 @@ def default_journal_location(journal_file, journal_dir, config_on_disk, temp_dir def config_var_on_disk(config_on_disk, journal_name, it_should, some_yaml): actual = config_on_disk if journal_name: + logger.info(f'Condition in body log is: journal_name') # STRUDEL_LOG etsi actual = actual["journals"][journal_name] expected = YAML(typ="safe").load(some_yaml) actual_slice = actual if isinstance(actual, dict): + logger.info(f'Condition in body log is: actual is type: dict') # STRUDEL_LOG dqjv # `expected` objects formatted in yaml only compare one level deep actual_slice = {key: actual.get(key) for key in expected.keys()} @@ -191,12 +196,14 @@ def config_var_on_disk(config_on_disk, journal_name, it_should, some_yaml): def config_var_in_memory(config_in_memory, journal_name, it_should, some_yaml): actual = config_in_memory["overrides"] if journal_name: + logger.info(f'Condition in body log is: journal_name') # STRUDEL_LOG ulkm actual = actual["journals"][journal_name] expected = YAML(typ="safe").load(some_yaml) actual_slice = actual if isinstance(actual, dict): + logger.info(f'Condition in body log is: actual is type: dict') # STRUDEL_LOG rnbf # `expected` objects formatted in yaml only compare one level deep actual_slice = {key: get_nested_val(actual, key) for key in expected.keys()} @@ -272,6 +279,7 @@ def content_of_file_should_be(file_path, file_content, cache_dir): for actual_line, expected_line in zip(actual_content, expected_content): if actual_line.startswith("tags: ") and expected_line.startswith("tags: "): + logger.info(f'Condition in body log is: actual_line.startswith( "tags: ") BoolOp expected_line.startswith( "tags: ")') # STRUDEL_LOG mcja assert_equal_tags_ignoring_order( actual_line, expected_line, actual_content, expected_content ) @@ -300,9 +308,11 @@ def cache_dir_contains_files(file_list, cache_dir): def assert_output_is_valid_language(cli_run, language_name): language_name = language_name.upper() if language_name == "XML": + logger.info(f'Condition in body log is: language_name({language_name}) = "XML"') # STRUDEL_LOG dxkz xml_tree = ElementTree.fromstring(cli_run["stdout"]) assert xml_tree, "Invalid XML" elif language_name == "JSON": + logger.info(f'Condition in body log is: language_name({language_name}) = "JSON"') # STRUDEL_LOG boxr assert json.loads(cli_run["stdout"]), "Invalid JSON" else: assert False, f"Language name {language_name} not recognized" @@ -314,6 +324,7 @@ def assert_parsed_output_item_count(node_name, number, parsed_output): obj = parsed_output["obj"] if lang == "XML": + logger.info(f'Condition in body log is: lang({lang}) = "XML"') # STRUDEL_LOG erlc xml_node_names = (node.tag for node in obj) assert node_name in xml_node_names, str(list(xml_node_names)) @@ -321,6 +332,7 @@ def assert_parsed_output_item_count(node_name, number, parsed_output): assert actual_entry_count == number, actual_entry_count elif lang == "JSON": + logger.info(f'Condition in body log is: lang({lang}) = "JSON"') # STRUDEL_LOG vtrh my_obj = obj for node in node_name.split("."): @@ -342,13 +354,16 @@ def assert_output_field_content(field_name, comparison, expected_keys, parsed_ou obj = parsed_output["obj"] expected_keys = expected_keys.split("\n") if len(expected_keys) == 1: + logger.info(f'Condition in body log is: len( expected_keys) = 1') # STRUDEL_LOG jtiw expected_keys = expected_keys[0] if lang == "XML": + logger.info(f'Condition in body log is: lang({lang}) = "XML"') # STRUDEL_LOG sjoz xml_node_names = (node.tag for node in obj) assert field_name in xml_node_names, str(list(xml_node_names)) if field_name == "tags": + logger.info(f'Condition in body log is: field_name({field_name}) = "tags"') # STRUDEL_LOG ocyv actual_tags = set(t.attrib["name"] for t in obj.find("tags")) assert set(actual_tags) == set(expected_keys), [ actual_tags, @@ -358,6 +373,7 @@ def assert_output_field_content(field_name, comparison, expected_keys, parsed_ou assert False, "This test only works for tags in XML" elif lang == "JSON": + logger.info(f'Condition in body log is: lang({lang}) = "JSON"') # STRUDEL_LOG encw my_obj = obj for node in field_name.split("."): @@ -368,7 +384,9 @@ def assert_output_field_content(field_name, comparison, expected_keys, parsed_ou my_obj = my_obj[node] if comparison == "be": + logger.info(f'Condition in body log is: comparison({comparison}) = "be"') # STRUDEL_LOG nciy if isinstance(my_obj, str): + logger.info(f'Condition in body log is: my_obj is type: str') # STRUDEL_LOG axdm assert expected_keys == my_obj, [my_obj, expected_keys] else: assert set(expected_keys) == set(my_obj), [ @@ -376,7 +394,9 @@ def assert_output_field_content(field_name, comparison, expected_keys, parsed_ou set(expected_keys), ] elif comparison == "contain": + logger.info(f'Condition in body log is: comparison({comparison}) = "contain"') # STRUDEL_LOG fmfm if isinstance(my_obj, str): + logger.info(f'Condition in body log is: my_obj is type: str') # STRUDEL_LOG qtfe assert expected_keys in my_obj, [my_obj, expected_keys] else: assert all(elem in my_obj for elem in expected_keys), [ @@ -405,6 +425,7 @@ def count_editor_args(num_args, cli_run, editor_state, it_should): assert cli_run["mocks"]["editor"].called == it_should if isinstance(num_args, int): + logger.info(f'Condition in body log is: num_args is type: int') # STRUDEL_LOG mthy assert len(editor_state["command"]) == int(num_args) @@ -427,8 +448,10 @@ def contains_editor_file(comparison, str_value, editor_state): content = editor_state["tmpfile"]["content"] # content = f'\n"""\n{content}\n"""\n' if comparison == "be": + logger.info(f'Condition in body log is: comparison({comparison}) = "be"') # STRUDEL_LOG hrup assert content == str_value elif comparison == "contain": + logger.info(f'Condition in body log is: comparison({comparison}) = "contain"') # STRUDEL_LOG ytoz assert str_value in content else: - assert False, f"Comparison '{comparison}' not supported" + assert False, f"Comparison '{comparison}' not supported" \ No newline at end of file diff --git a/tests/lib/type_builders.py b/tests/lib/type_builders.py index 16171ef0..3b7b8770 100644 --- a/tests/lib/type_builders.py +++ b/tests/lib/type_builders.py @@ -8,4 +8,4 @@ should_choice = TypeBuilder.make_enum( "should": True, "should not": False, } -) +) \ No newline at end of file diff --git a/tests/lib/when_steps.py b/tests/lib/when_steps.py index 71252f86..f22eb4f8 100644 --- a/tests/lib/when_steps.py +++ b/tests/lib/when_steps.py @@ -15,6 +15,7 @@ from jrnl.main import run @when(parse('we change directory to "{directory_name}"')) def when_we_change_directory(directory_name): if not os.path.isdir(directory_name): + logger.info(f'Condition in body log is: UnaryOp os.path.isdir( directory_name)') # STRUDEL_LOG ahcx os.mkdir(directory_name) os.chdir(directory_name) @@ -62,4 +63,4 @@ def we_run_jrnl(capsys, keyring, request, command, input_method, all_input): captured = capsys.readouterr() cli_run["stdout"] = captured.out - cli_run["stderr"] = captured.err + cli_run["stderr"] = captured.err \ No newline at end of file diff --git a/tests/unit/test_color.py b/tests/unit/test_color.py index 50ed2bdd..e8a1944d 100644 --- a/tests/unit/test_color.py +++ b/tests/unit/test_color.py @@ -18,4 +18,4 @@ def test_colorize(data_fixture): string = data_fixture colorized_string = colorize(string, "BLUE", True) - assert colorized_string == Style.BRIGHT + Fore.BLUE + string + Style.RESET_ALL + assert colorized_string == Style.BRIGHT + Fore.BLUE + string + Style.RESET_ALL \ No newline at end of file diff --git a/tests/unit/test_config_file.py b/tests/unit/test_config_file.py index d90dde35..e256bae2 100644 --- a/tests/unit/test_config_file.py +++ b/tests/unit/test_config_file.py @@ -24,4 +24,4 @@ def test_find_alt_config_not_exist(request): with pytest.raises(JrnlException) as ex: found_alt_config = find_alt_config(bad_config_path) assert found_alt_config is not None - assert isinstance(ex.value, JrnlException) + assert isinstance(ex.value, JrnlException) \ No newline at end of file diff --git a/tests/unit/test_controller.py b/tests/unit/test_controller.py index c6c1b4d8..98faaf2b 100644 --- a/tests/unit/test_controller.py +++ b/tests/unit/test_controller.py @@ -52,4 +52,4 @@ def test_display_search_results_builtin_plugins( mock_exporter.assert_called_once_with(export_format) mock_export.assert_called_once_with(test_journal, test_filename) - mock_print.assert_called_once_with(mock_export.return_value) + mock_print.assert_called_once_with(mock_export.return_value) \ No newline at end of file diff --git a/tests/unit/test_editor.py b/tests/unit/test_editor.py index 5c21daca..5ffcf58e 100644 --- a/tests/unit/test_editor.py +++ b/tests/unit/test_editor.py @@ -1,45 +1,45 @@ -# Copyright © 2012-2023 jrnl contributors -# License: https://www.gnu.org/licenses/gpl-3.0.html - -import os -from unittest.mock import mock_open -from unittest.mock import patch - -import pytest - -from jrnl.editor import get_template_path -from jrnl.editor import read_template_file -from jrnl.exception import JrnlException - - -@patch( - "os.getcwd", side_effect="/" -) # prevent failures in CI if current directory has been deleted -@patch("builtins.open", side_effect=FileNotFoundError()) -def test_read_template_file_with_no_file_raises_exception(mock_open, mock_getcwd): - with pytest.raises(JrnlException) as ex: - read_template_file("invalid_file.txt") - assert isinstance(ex.value, JrnlException) - - -@patch( - "os.getcwd", side_effect="/" -) # prevent failures in CI if current directory has been deleted -@patch("builtins.open", new_callable=mock_open, read_data="template text") -def test_read_template_file_with_valid_file_returns_text(mock_file, mock_getcwd): - assert read_template_file("valid_file.txt") == "template text" - - -def test_get_template_path_when_exists_returns_correct_path(): - with patch("os.path.exists", return_value=True): - output = get_template_path("template", "templatepath") - - assert output == os.path.join("templatepath", "template") - - -@patch("jrnl.editor.absolute_path") -def test_get_template_path_when_doesnt_exist_returns_correct_path(mock_absolute_paths): - with patch("os.path.exists", return_value=False): - output = get_template_path("template", "templatepath") - - assert output == mock_absolute_paths.return_value +# Copyright © 2012-2023 jrnl contributors +# License: https://www.gnu.org/licenses/gpl-3.0.html + +import os +from unittest.mock import mock_open +from unittest.mock import patch + +import pytest + +from jrnl.editor import get_template_path +from jrnl.editor import read_template_file +from jrnl.exception import JrnlException + + +@patch( + "os.getcwd", side_effect="/" +) # prevent failures in CI if current directory has been deleted +@patch("builtins.open", side_effect=FileNotFoundError()) +def test_read_template_file_with_no_file_raises_exception(mock_open, mock_getcwd): + with pytest.raises(JrnlException) as ex: + read_template_file("invalid_file.txt") + assert isinstance(ex.value, JrnlException) + + +@patch( + "os.getcwd", side_effect="/" +) # prevent failures in CI if current directory has been deleted +@patch("builtins.open", new_callable=mock_open, read_data="template text") +def test_read_template_file_with_valid_file_returns_text(mock_file, mock_getcwd): + assert read_template_file("valid_file.txt") == "template text" + + +def test_get_template_path_when_exists_returns_correct_path(): + with patch("os.path.exists", return_value=True): + output = get_template_path("template", "templatepath") + + assert output == os.path.join("templatepath", "template") + + +@patch("jrnl.editor.absolute_path") +def test_get_template_path_when_doesnt_exist_returns_correct_path(mock_absolute_paths): + with patch("os.path.exists", return_value=False): + output = get_template_path("template", "templatepath") + + assert output == mock_absolute_paths.return_value \ No newline at end of file diff --git a/tests/unit/test_export.py b/tests/unit/test_export.py index 10e9dd6b..f6cf95c9 100644 --- a/tests/unit/test_export.py +++ b/tests/unit/test_export.py @@ -44,4 +44,4 @@ class TestYaml: ) with pytest.raises(JrnlException): YAMLExporter.write_file("journal", "non-existing-path") - mock_open.assert_not_called() + mock_open.assert_not_called() \ No newline at end of file diff --git a/tests/unit/test_install.py b/tests/unit/test_install.py index 1c6c0924..8657faaa 100644 --- a/tests/unit/test_install.py +++ b/tests/unit/test_install.py @@ -14,4 +14,4 @@ def test_initialize_autocomplete_runs_without_readline(): from jrnl import install with mock.patch.dict(sys.modules, {"readline": None}): - install._initialize_autocomplete() # should not throw exception + install._initialize_autocomplete() # should not throw exception \ No newline at end of file diff --git a/tests/unit/test_os_compat.py b/tests/unit/test_os_compat.py index 88b678a8..fcc2b1d6 100644 --- a/tests/unit/test_os_compat.py +++ b/tests/unit/test_os_compat.py @@ -88,4 +88,4 @@ def test_split_args_on_windows(args): def test_split_args_on_not_windows(args): input_arguments, expected_split_args = args[0], args[1] with mock.patch("jrnl.os_compat.on_windows", lambda: True): - assert split_args(input_arguments) == expected_split_args + assert split_args(input_arguments) == expected_split_args \ No newline at end of file diff --git a/tests/unit/test_output.py b/tests/unit/test_output.py index 6797ba6c..af77b7bd 100644 --- a/tests/unit/test_output.py +++ b/tests/unit/test_output.py @@ -25,4 +25,4 @@ def test_print_msg_calls_print_msgs_with_kwargs(print_msgs): "some_rando_arg": "💩", } print_msg(test_msg, **kwargs) - print_msgs.assert_called_once_with([test_msg], style=test_msg.style, **kwargs) + print_msgs.assert_called_once_with([test_msg], style=test_msg.style, **kwargs) \ No newline at end of file diff --git a/tests/unit/test_override.py b/tests/unit/test_override.py index 25fd085d..cb131527 100644 --- a/tests/unit/test_override.py +++ b/tests/unit/test_override.py @@ -108,4 +108,4 @@ class TestDotNotationToList: def test_sequential_delimiters(self): k = "g.r..h.v" k_l = _convert_dots_to_list(k) - assert len(k_l) == 4 + assert len(k_l) == 4 \ No newline at end of file diff --git a/tests/unit/test_parse_args.py b/tests/unit/test_parse_args.py index e3036020..b836f3ee 100644 --- a/tests/unit/test_parse_args.py +++ b/tests/unit/test_parse_args.py @@ -311,4 +311,4 @@ class TestDeserialization: assert cfg["editor"] == "vi -c startinsert" cfg = make_yaml_valid_dict(["highlight", "true"]) - assert cfg["highlight"] is True + assert cfg["highlight"] is True \ No newline at end of file diff --git a/tests/unit/test_path.py b/tests/unit/test_path.py index 8df73b68..e14043a2 100644 --- a/tests/unit/test_path.py +++ b/tests/unit/test_path.py @@ -103,4 +103,4 @@ def test_absolute_path(mock_abspath, mock_expand_path): assert absolute_path(test_val) == mock_abspath.return_value mock_expand_path.assert_called_with(test_val) - mock_abspath.assert_called_with(mock_expand_path.return_value) + mock_abspath.assert_called_with(mock_expand_path.return_value) \ No newline at end of file diff --git a/tests/unit/test_time.py b/tests/unit/test_time.py index 1901a4dc..cc6577c2 100644 --- a/tests/unit/test_time.py +++ b/tests/unit/test_time.py @@ -41,4 +41,4 @@ def test_default_minute_is_added(): ) def test_is_valid_date(inputs): year, month, day, expected_result = inputs - assert time.is_valid_date(year, month, day) == expected_result + assert time.is_valid_date(year, month, day) == expected_result \ No newline at end of file