Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions lib/rift/Controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,9 @@
from rift.TextTable import TextTable
from rift.VM import VM
from rift.sync import RepoSyncFactory
from rift.utils import message, banner


def message(msg):
"""
helper function to print a log message
"""
print(f"> {msg}")

def banner(title):
"""
helper function to print a banner
"""
print(f"** {title} **")

def make_parser():
"""Create command line parser"""

Expand Down
12 changes: 12 additions & 0 deletions lib/rift/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@

from rift import RiftError

def message(msg):
"""
helper function to print a log message
"""
print(f"> {msg}")

def banner(title):
"""
helper function to print a banner
"""
print(f"** {title} **")

def download_file(url, output):
"""
Download file pointed by url and save it in output path. Convert
Expand Down
21 changes: 21 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Copyright (C) 2025 CEA
#

from io import StringIO
from unittest.mock import patch

from TestUtils import RiftTestCase
from rift.utils import message, banner

class UtilsTest(RiftTestCase):

@patch('sys.stdout', new_callable=StringIO)
def test_message(self, mock_stdout):
message("foo")
self.assertEqual(mock_stdout.getvalue(), "> foo\n")

@patch('sys.stdout', new_callable=StringIO)
def test_banner(self, mock_stdout):
banner("bar")
self.assertEqual(mock_stdout.getvalue(), "** bar **\n")