diff options
author | Erik Rose <grinch@grinchcentral.com> | 2015-03-04 22:04:55 -0500 |
---|---|---|
committer | Erik Rose <grinch@grinchcentral.com> | 2015-03-04 22:04:55 -0500 |
commit | 01282716b2554dc1fc99af16ba3bb84acd5903df (patch) | |
tree | 78bd1c30f7b1bb0c70c4b4985fc5d28e97aed183 | |
parent | 7360504d365d08e500adfb20ec0df3308f4ff6b5 (diff) | |
parent | 339d07cc7e72e50a6334ddb6b5e08cfcf8111dff (diff) | |
download | blessings-01282716b2554dc1fc99af16ba3bb84acd5903df.tar.gz |
Merge pull request #91 from erikrose/blessed-integration-freebsd-support
-rw-r--r-- | .coveragerc | 4 | ||||
-rw-r--r-- | .prospector.yaml | 2 | ||||
-rw-r--r-- | blessings/_binterms.py | 1 | ||||
-rw-r--r-- | blessings/tests/test_core.py | 26 | ||||
-rw-r--r-- | blessings/tests/test_sequences.py | 21 | ||||
-rwxr-xr-x | tools/display-sighandlers.py | 6 | ||||
-rwxr-xr-x | tools/teamcity-runtests.sh | 3 | ||||
-rw-r--r-- | tox.ini | 2 |
8 files changed, 41 insertions, 24 deletions
diff --git a/.coveragerc b/.coveragerc index eb47214..078f566 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,6 @@ [run] branch = True -source = blessed +source = blessings [report] -omit = blessed/tests/* +omit = blessings/tests/* diff --git a/.prospector.yaml b/.prospector.yaml index d6714ed..5d1f7d2 100644 --- a/.prospector.yaml +++ b/.prospector.yaml @@ -6,7 +6,7 @@ ignore: - ^docs/ # ignore tests and bin/ for the moment, their quality does not so much matter. - ^bin/ - - ^blessed/tests/ + - ^blessings/tests/ test-warnings: true 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..8d1597e 100644 --- a/blessings/tests/test_sequences.py +++ b/blessings/tests/test_sequences.py @@ -95,7 +95,6 @@ def test_stream_attr(): def test_emit_warnings_about_binpacked(): """Test known binary-packed terminals (kermit, avatar) emit a warning.""" from blessings.sequences import _BINTERM_UNSUPPORTED_MSG - from blessings._binterms import binary_terminals @as_subprocess def child(kind): @@ -115,19 +114,25 @@ def test_emit_warnings_about_binpacked(): assert 'warnings should have been emitted.' warnings.resetwarnings() - # any binary terminal should do. - child(binary_terminals[random.randrange(len(binary_terminals))]) + # Although any binary terminal should do, FreeBSD has "termcap entry bugs" + # that cause false negatives, because their underlying curses library emits + # some kind of "warning" to stderr, which our @as_subprocess decorator + # determines to be noteworthy enough to fail the test: + # https://gist.github.com/jquast/7b90af251fe4000baa09 + # + # so we chose only one of beautiful lineage: + # http://terminals.classiccmp.org/wiki/index.php/Tektronix_4207 + child(kind='tek4207-s') def test_unit_binpacked_unittest(): """Unit Test known binary-packed terminals emit a warning (travis-safe).""" import warnings - from blessings._binterms import binary_terminals from blessings.sequences import (_BINTERM_UNSUPPORTED_MSG, init_sequence_patterns) warnings.filterwarnings("error", category=UserWarning) term = mock.Mock() - term.kind = binary_terminals[random.randrange(len(binary_terminals))] + term.kind = 'tek4207-s' try: init_sequence_patterns(term) @@ -192,8 +197,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 +216,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)" diff --git a/tools/teamcity-runtests.sh b/tools/teamcity-runtests.sh index 07b06e9..3b3faec 100755 --- a/tools/teamcity-runtests.sh +++ b/tools/teamcity-runtests.sh @@ -1,7 +1,4 @@ #!/bin/bash -# -# This script assumes that the project 'ptyprocess' is -# available in the parent of the project's folder. set -e set -o pipefail @@ -18,7 +18,7 @@ deps = pytest-xdist commands = {envbindir}/py.test \ --strict --junit-xml=results.{envname}.xml \ --verbose --verbose \ - --cov blessings blessings/tests --cov-report=term-missing \ + --cov blessings --cov-report=term-missing \ {posargs} /bin/mv {toxinidir}/.coverage {toxinidir}/.coverage.{envname} |