More repr tests.
parent
bc66db94aa
commit
dbe98c664a
|
@ -104,6 +104,6 @@ class _STIXBase(collections.Mapping):
|
|||
separators=(",", ": ")) # Don't include spaces after commas.
|
||||
|
||||
def __repr__(self):
|
||||
props = [(k, self[k]) for k in sorted(self._properties)]
|
||||
props = [(k, self[k]) for k in sorted(self._properties) if self.get(k)]
|
||||
return "{0}({1})".format(self.__class__.__name__,
|
||||
", ".join(["{0!s}={1!r}".format(k, v) for k, v in props]))
|
||||
|
|
|
@ -34,6 +34,7 @@ def test_external_reference_capec():
|
|||
)
|
||||
|
||||
assert str(ref) == CAPEC
|
||||
assert repr(ref) == "ExternalReference(external_id='CAPEC-550', source_name='capec')"
|
||||
|
||||
|
||||
CAPEC_URL = """{
|
||||
|
@ -100,6 +101,9 @@ def test_external_reference_offline():
|
|||
)
|
||||
|
||||
assert str(ref) == OFFLINE
|
||||
assert repr(ref) == "ExternalReference(description='Threat report', source_name='ACME Threat Intel')"
|
||||
# Yikes! This works
|
||||
assert eval("stix2." + repr(ref)) == ref
|
||||
|
||||
|
||||
def test_external_reference_source_required():
|
||||
|
|
Loading…
Reference in New Issue