diff options
author | Erik Rose <erik@mozilla.com> | 2011-11-15 13:47:19 -0800 |
---|---|---|
committer | Erik Rose <erik@mozilla.com> | 2011-11-15 13:47:19 -0800 |
commit | e90c368aa79b55a86f77cb03fe071c3515ffbc6b (patch) | |
tree | 4aee6c7612a3ea2358fbdc4ffdd616b6c230373a /blessings/tests.py | |
parent | 8c1e1a701429a2a832be6613c006d626a63dd2ac (diff) | |
download | blessings-e90c368aa79b55a86f77cb03fe071c3515ffbc6b.tar.gz |
Let location() operate on just an x *or* y coordinate.
Use force_styling in a test so we don't have to mock things anymore.
Diffstat (limited to 'blessings/tests.py')
-rw-r--r-- | blessings/tests.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/blessings/tests.py b/blessings/tests.py index b45116e..df71192 100644 --- a/blessings/tests.py +++ b/blessings/tests.py @@ -54,19 +54,22 @@ def test_stream_attr(): def test_location(): """Make sure ``location()`` does what it claims.""" - # Let the Terminal grab the actual tty and call setupterm() so things work: - t = Terminal() - - # Then rip it away, replacing it with something we can check later: - output = t.stream = StringIO() + t = Terminal(stream=StringIO(), force_styling=True) with t.location(3, 4): - output.write('hi') + t.stream.write('hi') - eq_(output.getvalue(), tigetstr('sc') + - tparm(tigetstr('cup'), 4, 3) + - 'hi' + - tigetstr('rc')) + eq_(t.stream.getvalue(), tigetstr('sc') + + tparm(tigetstr('cup'), 4, 3) + + 'hi' + + tigetstr('rc')) + +def test_horizontal_location(): + """Make sure we can move the cursor horizontally without changing rows.""" + t = Terminal(stream=StringIO(), force_styling=True) + with t.location(x=5): + pass + eq_(t.stream.getvalue(), t.save + tparm(tigetstr('hpa'), 5) + t.restore) def test_null_fileno(): |