summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Quast <contact@jeffquast.com>2015-02-27 20:44:34 -0800
committerJeff Quast <contact@jeffquast.com>2015-02-27 20:44:34 -0800
commit59db6acca3a5ceb9d9eb22096de2f5c0e396154c (patch)
tree66e3b353360cd441cf16e6b8ccf36883132a54db
parent3d8ea2b1ce2bd66018d1d08bf7105089ba495bf6 (diff)
downloadblessings-59db6acca3a5ceb9d9eb22096de2f5c0e396154c.tar.gz
Minor fixes, ensuring tests pass on FreeBSD
- do not test 'ansi' hpa/vpa: On FreeBSD, ansi has no such capability. This is the reason such "proxies" exist, anyway. - workaround for freebsd, which actually has an 'unknown' termcap entry - 'ansi' on freebsd tests '0' for number of colors, use cons25 on such system. - freebsd: handle ValueError in signal.getsignal in the accessory script ``tools/display-signalhandlers.py``, we don't actually **need** this script, it is just chained as part of the build to help in debugging issues with any given build agent, and any gven OS problem reports.
-rw-r--r--blessings/_binterms.py1
-rw-r--r--blessings/tests/test_core.py26
-rw-r--r--blessings/tests/test_sequences.py6
-rwxr-xr-xtools/display-sighandlers.py6
4 files changed, 27 insertions, 12 deletions
diff --git a/blessings/_binterms.py b/blessings/_binterms.py
index 6c93ee0..504bc9c 100644
--- a/blessings/_binterms.py
+++ b/blessings/_binterms.py
@@ -707,7 +707,6 @@ tvi950-rv
tvi950-rv-2p
tvi950-rv-4p
tvipt
-unknown
vanilla
vc303
vc404
diff --git a/blessings/tests/test_core.py b/blessings/tests/test_core.py
index ce1e838..cea2eaf 100644
--- a/blessings/tests/test_core.py
+++ b/blessings/tests/test_core.py
@@ -107,7 +107,12 @@ def test_number_of_colors_without_tty():
@as_subprocess
def child_8_forcestyle():
- t = TestTerminal(kind='ansi', stream=StringIO(),
+ kind = 'ansi'
+ if platform.system().lower() == 'freebsd':
+ # 'ansi' on freebsd returns 0 colors, we use the 'cons25' driver,
+ # compatible with its kernel tty.c
+ kind = 'cons25'
+ t = TestTerminal(kind=kind, stream=StringIO(),
force_styling=True)
assert (t.number_of_colors == 8)
@@ -132,7 +137,12 @@ def test_number_of_colors_with_tty():
@as_subprocess
def child_8():
- t = TestTerminal(kind='ansi')
+ kind = 'ansi'
+ if platform.system().lower() == 'freebsd':
+ # 'ansi' on freebsd returns 0 colors, we use the 'cons25' driver,
+ # compatible with its kernel tty.c
+ kind = 'cons25'
+ t = TestTerminal(kind=kind)
assert (t.number_of_colors == 8)
@as_subprocess
@@ -201,9 +211,10 @@ def test_setupterm_singleton_issue33():
def test_setupterm_invalid_issue39():
"A warning is emitted if TERM is invalid."
# https://bugzilla.mozilla.org/show_bug.cgi?id=878089
-
+ #
# if TERM is unset, defaults to 'unknown', which should
- # fail to lookup and emit a warning, only.
+ # fail to lookup and emit a warning on *some* systems.
+ # freebsd actually has a termcap entry for 'unknown'
@as_subprocess
def child():
warnings.filterwarnings("error", category=UserWarning)
@@ -216,8 +227,9 @@ def test_setupterm_invalid_issue39():
"Failed to setupterm(kind='unknown'): "
"setupterm: could not find terminal")
else:
- assert not term.is_a_tty and not term.does_styling, (
- 'Should have thrown exception')
+ if platform.system().lower() != 'freebsd':
+ assert not term.is_a_tty and not term.does_styling, (
+ 'Should have thrown exception')
warnings.resetwarnings()
child()
@@ -233,7 +245,7 @@ def test_setupterm_invalid_has_no_styling():
def child():
warnings.filterwarnings("ignore", category=UserWarning)
- term = TestTerminal(kind='unknown', force_styling=True)
+ term = TestTerminal(kind='xxXunknownXxx', force_styling=True)
assert term.kind is None
assert term.does_styling is False
assert term.number_of_colors == 0
diff --git a/blessings/tests/test_sequences.py b/blessings/tests/test_sequences.py
index f42a52c..c0cafce 100644
--- a/blessings/tests/test_sequences.py
+++ b/blessings/tests/test_sequences.py
@@ -192,8 +192,8 @@ def test_horizontal_location(all_terms):
assert (t.stream.getvalue() == expected_output), (
repr(t.stream.getvalue()), repr(expected_output))
- # skip 'screen', hpa is proxied (see later tests)
- if all_terms != 'screen':
+ # skip 'screen', 'ansi': hpa is proxied (see later tests)
+ if all_terms not in ('screen', 'ansi'):
child(all_terms)
@@ -211,7 +211,7 @@ def test_vertical_location(all_terms):
assert (t.stream.getvalue() == expected_output)
# skip 'screen', vpa is proxied (see later tests)
- if all_terms != 'screen':
+ if all_terms not in ('screen', 'ansi'):
child(all_terms)
diff --git a/tools/display-sighandlers.py b/tools/display-sighandlers.py
index 98445e9..f3559f7 100755
--- a/tools/display-sighandlers.py
+++ b/tools/display-sighandlers.py
@@ -12,7 +12,11 @@ for name, value in [(signal_name, getattr(signal, signal_name))
for signal_name in dir(signal)
if signal_name.startswith('SIG')
and not signal_name.startswith('SIG_')]:
- handler = signal.getsignal(value)
+ try:
+ handler = signal.getsignal(value)
+ except ValueError:
+ # FreeBSD: signal number out of range
+ handler = 'out of range'
description = {
signal.SIG_IGN: "ignored(SIG_IGN)",
signal.SIG_DFL: "default(SIG_DFL)"