From dace0316a2c60a8074ee1802012c2467b8e3412e Mon Sep 17 00:00:00 2001 From: Greg Becker Date: Thu, 1 Jun 2023 00:08:45 -0700 Subject: [PATCH] Spec.format: print false attributes if requested (#37932) --- lib/spack/spack/spec.py | 2 +- lib/spack/spack/test/spec_semantics.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 16051524509..e29e3b2f85b 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -4333,7 +4333,7 @@ def write_attribute(spec, attribute, color): if callable(current): raise SpecFormatStringError("Attempted to format callable object") - if not current: + if current is None: # We're not printing anything return diff --git a/lib/spack/spack/test/spec_semantics.py b/lib/spack/spack/test/spec_semantics.py index bd752612223..1a6a08b41ed 100644 --- a/lib/spack/spack/test/spec_semantics.py +++ b/lib/spack/spack/test/spec_semantics.py @@ -660,6 +660,7 @@ def test_spec_formatting(self, default_mock_concretization): ("{architecture.os}", "", "os", lambda spec: spec.architecture), ("{architecture.target}", "", "target", lambda spec: spec.architecture), ("{prefix}", "", "prefix", lambda spec: spec), + ("{external}", "", "external", lambda spec: spec), # test we print "False" ] hash_segments = [