Add repr and str dunder functions

* Add __repr__ function that prints the object representation.
* Add __str__ function that prints the Badge SVG text.

Also:
* Add constructor args to the Badge class docstring.
* Change the way defaults are used in the Badge constuctor.  Instead of
  setting values, use None and set arguments to the default values inside
  the constructor.
* Fix unittests that don't use overwrite=True.
This commit is contained in:
Jon Grace-Cox
2019-06-01 23:05:16 -04:00
parent b88eb5fc07
commit 4bdb6dcdab
2 changed files with 110 additions and 6 deletions

View File

@@ -94,7 +94,7 @@ class TestAnybadge(TestCase):
badge = Badge('test', '2.22', value_suffix='%',
thresholds=thresholds)
badge.write_badge('test_badge_8.svg')
badge.write_badge('test_badge_8.svg', overwrite=True)
def test_badge_with_text_color(self):
"""Test generating a badge with alternate text_color."""
@@ -102,4 +102,4 @@ class TestAnybadge(TestCase):
badge = Badge('test', '2.22', value_suffix='%',
text_color='#010101,#101010')
badge.write_badge('test_badge_9.svg')
badge.write_badge('test_badge_9.svg', overwrite=True)