From a1c72448cff540c9d6e610f3973a70cf495aadb6 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Wed, 21 Mar 2018 17:40:41 -0400 Subject: Fix unit tests on macOS when gnureadline is installed As similar try/except needed to be added to a couple unit test files to try to import gnureadline as readline and fallback to importing readline. --- tests/test_argparse.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tests/test_argparse.py') diff --git a/tests/test_argparse.py b/tests/test_argparse.py index fb8836f3..ae3bde98 100644 --- a/tests/test_argparse.py +++ b/tests/test_argparse.py @@ -5,7 +5,6 @@ Cmd2 testing for argument parsing import argparse import functools import pytest -import readline import sys import cmd2 @@ -14,6 +13,18 @@ import six from conftest import run_cmd, StdOut +# Prefer statically linked gnureadline if available (for macOS compatibility due to issues with libedit) +try: + import gnureadline as readline +except ImportError: + # Try to import readline, but allow failure for convenience in Windows unit testing + # Note: If this actually fails, you should install readline on Linux or Mac or pyreadline on Windows + try: + # noinspection PyUnresolvedReferences + import readline + except ImportError: + pass + class ArgparseApp(cmd2.Cmd): def __init__(self): -- cgit v1.2.1