From 13a302b6537469ecf6c87d06f08adde8fd687822 Mon Sep 17 00:00:00 2001 From: Vaughn Kottler Date: Sat, 14 Oct 2023 22:47:41 -0500 Subject: [PATCH] Don't run TUI tests if curses isn't found --- tests/test_entry.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test_entry.py b/tests/test_entry.py index 3abe8045..014442d0 100644 --- a/tests/test_entry.py +++ b/tests/test_entry.py @@ -3,6 +3,7 @@ """ # built-in +import importlib from subprocess import check_output from sys import executable from unittest.mock import patch @@ -35,8 +36,13 @@ def test_package_entry(): def test_entry_tui_cmd(): """Test basic usages of the 'tui' command.""" - base = base_args("tui") + try: + # Only run these tests if the curses module is present. + importlib.import_module("curses") + base = base_args("tui") - with patch("runtimepy.commands.tui._curses.wrapper", new=wrapper_mock): - # Only run 20 iterations. - assert runtimepy_main(base + ["-i", "20"]) == 0 + with patch("runtimepy.commands.tui._curses.wrapper", new=wrapper_mock): + # Only run 20 iterations. + assert runtimepy_main(base + ["-i", "20"]) == 0 + except ImportError: + pass