diff mbox series

[b4,v2,2/6] src/tests: fix trailer test hiding parser errors

Message ID 20241027-trailer-special-chars-v2-2-e963f78b3ef8@gmail.com (mailing list archive)
State New
Headers show
Series Handle patch trailers with special characters | expand

Commit Message

Brandon Maier Oct. 27, 2024, 10:34 p.m. UTC
The trailer parsing test compares the values of the b4.LoreTrailer
object created from the test input against a b4.LoreTrailer object
created from our expected test input.

This means if there is an error in how b4.LoreTrailer parses input, it
won't be detected. This was discovered from a reported bug with parsing
email trailers with embedded ','.

Bug: https://github.com/mricon/b4/issues/50
---
 src/tests/test___init__.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/tests/test___init__.py b/src/tests/test___init__.py
index dbc92c7e8352728c2f2a951f7b9b1496ccbaf2c5..7fe43b0158460f06d0a2b52d2689d26e7ef7f840 100644
--- a/src/tests/test___init__.py
+++ b/src/tests/test___init__.py
@@ -57,7 +57,7 @@  def test_save_git_am_mbox(sampledir, tmp_path, source, regex, flags, ismbox):
 
 @pytest.mark.parametrize('source,expected', [
     ('trailers-test-simple',
-     [('person', 'Reviewed-By', 'Bogus Bupkes <bogus@example.com>', None),
+     [('person', 'Reviewed-by', 'Bogus Bupkes <bogus@example.com>', None),
       ('utility', 'Fixes', 'abcdef01234567890', None),
       ('utility', 'Link', 'https://msgid.link/some@msgid.here', None),
       ]),
@@ -77,10 +77,14 @@  def test_parse_trailers(sampledir, source, expected):
         assert len(expected) == len(trs)
         for tr in trs:
             mytype, myname, myvalue, myextinfo = expected.pop(0)
+            assert tr.name == myname
+            assert tr.value == myvalue
+            assert tr.extinfo == myextinfo
+            assert tr.type == mytype
+
             mytr = b4.LoreTrailer(name=myname, value=myvalue, extinfo=myextinfo)
             assert tr == mytr
             assert tr.extinfo == mytr.extinfo
-            assert tr.type == mytype
 
 
 @pytest.mark.parametrize('source,serargs,amargs,reference,b4cfg', [