summaryrefslogtreecommitdiff
path: root/tests/test_argparse.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-03-21 17:56:58 -0400
committerGitHub <noreply@github.com>2018-03-21 17:56:58 -0400
commit3e085fdee07d65054a246a857a3e0f8816a738de (patch)
treeb0119c62cf1f480f1c6bbc7fcaffc9767f78db2d /tests/test_argparse.py
parent4cea62a8fb7f5da3cfd4ee32fde831f401c128dc (diff)
parenta1c72448cff540c9d6e610f3973a70cf495aadb6 (diff)
downloadcmd2-git-3e085fdee07d65054a246a857a3e0f8816a738de.tar.gz
Merge pull request #326 from python-cmd2/fix_unit_tests_gnureadline
Fix unit tests on macOS when gnureadline is installed
Diffstat (limited to 'tests/test_argparse.py')
-rw-r--r--tests/test_argparse.py13
1 files changed, 12 insertions, 1 deletions
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):