summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2022-02-01 21:59:29 +0100
committerGitHub <noreply@github.com>2022-02-01 21:59:29 +0100
commitb93b64ca67768dfb2c377dd9c64452cb60ad7e23 (patch)
tree186a5e08311c8184ada112aa3ec52299b9549b5e
parent7c31d4d27942a66e64d691af4fde4006128095e6 (diff)
downloadspack-b93b64ca67768dfb2c377dd9c64452cb60ad7e23.tar.gz
spack-b93b64ca67768dfb2c377dd9c64452cb60ad7e23.tar.bz2
spack-b93b64ca67768dfb2c377dd9c64452cb60ad7e23.tar.xz
spack-b93b64ca67768dfb2c377dd9c64452cb60ad7e23.zip
TermStatusLine: fix python 2.7 and add test (#28715)
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
-rw-r--r--lib/spack/spack/installer.py2
-rw-r--r--lib/spack/spack/test/installer.py11
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/spack/spack/installer.py b/lib/spack/spack/installer.py
index dec5bab626..d08e828c80 100644
--- a/lib/spack/spack/installer.py
+++ b/lib/spack/spack/installer.py
@@ -683,7 +683,7 @@ class TermStatusLine(object):
return
self.pkg_set.clear()
- self.pkg_list.clear()
+ self.pkg_list = []
# Move the cursor to the beginning of the first "Waiting for" message and clear
# everything after it.
diff --git a/lib/spack/spack/test/installer.py b/lib/spack/spack/test/installer.py
index 826c0534d3..bc1398afff 100644
--- a/lib/spack/spack/test/installer.py
+++ b/lib/spack/spack/test/installer.py
@@ -1272,3 +1272,14 @@ def test_overwrite_install_backup_failure(temporary_store, config, mock_packages
# Make sure that `remove` was called on the database after an unsuccessful
# attempt to restore the backup.
assert fake_db.called
+
+
+def test_term_status_line():
+ # Smoke test for TermStatusLine; to actually test output it would be great
+ # to pass a StringIO instance, but we use tty.msg() internally which does not
+ # accept that. `with log_output(buf)` doesn't really work because it trims output
+ # and we actually want to test for escape sequences etc.
+ x = inst.TermStatusLine(enabled=True)
+ x.add("a")
+ x.add("b")
+ x.clear()