Repository: mdolab/baseclasses

Issue:
CaseInsensitive containers do not work with pprint
## Description
The `CaseInsensitive` containers are not properly formatted when printed with `pprint`. This bug was introduced with the ABC implementation in #51. I realized this because the ADflow options dictionary is now printed in one massive line instead of having line breaks. The same bug applies to both `CaseInsensitiveDict` and `CaseInsensitiveSet`.

### Steps to reproduce issue
Here is a MWE for `CaseInsensitiveDict`:

```
from baseclasses.utils import CaseInsensitiveDict
from pprint import pprint

sensitive = {"b-longstring": 2, "a-longstring": 1, "c-longstring": 3, "e-longstring": 5, "d-longstring": 4}
insensitive = CaseInsensitiveDict(sensitive)

pprint(sensitive)
pprint(insensitive)
```

### Current behavior
```
>>> pprint(sensitive)
{'a-longstring': 1,
 'b-longstring': 2,
 'c-longstring': 3,
 'd-longstring': 4,
 'e-longstring': 5}

>>> pprint(insensitive)
{'b-longstring': 2, 'a-longstring': 1, 'c-longstring': 3, 'e-longstring': 5, 'd-longstring': 4}
```

### Expected behavior
```
>>> pprint(sensitive)
{'a-longstring': 1,
 'b-longstring': 2,
 'c-longstring': 3,
 'd-longstring': 4,
 'e-longstring': 5}

>>> pprint(insensitive)
{'a-longstring': 1,
 'b-longstring': 2,
 'c-longstring': 3,
 'd-longstring': 4,
 'e-longstring': 5}
```




Discussion:

Patch:
diff --git a/baseclasses/utils.py b/baseclasses/utils.py
index 61a8044..598b6fb 100644
--- a/baseclasses/utils.py
+++ b/baseclasses/utils.py
@@ -1,5 +1,6 @@
 from collections.abc import MutableMapping, MutableSet
 from typing import Any, Dict, Optional
+from pprint import pformat
 
 
 class CaseInsensitiveDict(MutableMapping):
@@ -93,7 +94,7 @@ class CaseInsensitiveDict(MutableMapping):
         return selfLower.__eq__(otherLower)
 
     def __repr__(self):
-        return str(self.data)
+        return pformat(self.data)
 
 
 class CaseInsensitiveSet(MutableSet):
@@ -202,7 +203,7 @@ class CaseInsensitiveSet(MutableSet):
         return lowerSelf.issubset(lowerOther)
 
     def __repr__(self):
-        return str(self.data)
+        return pformat(self.data)
 
 
 class Error(Exception):


Test patch:
diff --git a/tests/test_CaseInsensitve.py b/tests/test_CaseInsensitve.py
index 5b2b0d0..38931c0 100644
--- a/tests/test_CaseInsensitve.py
+++ b/tests/test_CaseInsensitve.py
@@ -1,5 +1,6 @@
 import unittest
 import pickle
+from pprint import pformat
 from baseclasses.utils import CaseInsensitiveDict, CaseInsensitiveSet
 from parameterized import parameterized
 from baseclasses.decorators import require_mpi
@@ -128,6 +129,14 @@ class TestCaseInsensitiveDict(unittest.TestCase):
     def test_repr(self):
         self.assertEqual(self.d2.__str__(), self.d2.data.__str__())
 
+    def test_repr_pprint(self):
+        long_dict = {"b-longstring": 2, "a-longstring": 1, "c-longstring": 3, "e-longstring": 5, "d-longstring": 4}
+        string_format = pformat(CaseInsensitiveDict(long_dict))
+        string_expected = (
+            "{'a-longstring': 1,\n 'b-longstring': 2,\n 'c-longstring': 3,\n 'd-longstring': 4,\n 'e-longstring': 5}"
+        )
+        self.assertEqual(string_format, string_expected)
+
 
 class TestCaseInsensitiveSet(unittest.TestCase):
     def setUp(self):
@@ -225,6 +234,14 @@ class TestCaseInsensitiveSet(unittest.TestCase):
     def test_repr(self):
         self.assertEqual(self.s2.__str__(), self.s2.data.__str__())
 
+    def test_repr_pprint(self):
+        long_set = {"a-longstring", "b-longstring", "c-longstring", "d-longstring", "e-longstring", "f-longstring"}
+        string_format = pformat(CaseInsensitiveSet(long_set))
+        string_expected = (
+            "{'a-longstring',\n 'b-longstring',\n 'c-longstring',\n 'd-longstring',\n 'e-longstring',\n 'f-longstring'}"
+        )
+        self.assertEqual(string_format, string_expected)
+
 
 class TestParallel(unittest.TestCase):
     N_PROCS = 2