diff --git a/crypto_condor/primitives/common.py b/crypto_condor/primitives/common.py index b520eb0..2652035 100644 --- a/crypto_condor/primitives/common.py +++ b/crypto_condor/primitives/common.py @@ -690,7 +690,7 @@ def print_results(self, res: Results | ResultsDict) -> None: def process_results( self, res: ResultsDict | Results, - filename: str = "", + filename: str | None = "", no_save: bool = False, debug_data: bool | None = None, ) -> bool: @@ -769,7 +769,7 @@ def process_results( subtitle=f"crypto-condor {padded_version} by Quarkslab", ) self.print(summary) - if no_save: + if no_save or filename is None: # Nothing more to do. return res.check() # Save results. diff --git a/tests/primitives/test_common.py b/tests/primitives/test_common.py new file mode 100644 index 0000000..6ce3ff2 --- /dev/null +++ b/tests/primitives/test_common.py @@ -0,0 +1,20 @@ +"""Module to test crypto_condor.primitives.common.""" + +from hashlib import sha256 +from pathlib import Path + +from crypto_condor.primitives import SHA +from crypto_condor.primitives.common import Console + + +class TestConsole: + """Tests for the Console class.""" + + def test_filename_none(self, tmp_path: Path): + """Tests passing None as filename. + + The expected behaviour is that the user is not prompted for a filename. + """ + rd = SHA.test(lambda msg: sha256(msg).digest(), SHA.Algorithm.SHA_256) + console = Console() + assert console.process_results(rd, None)