You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2020/08/15 06:02:28 UTC

[incubator-ponymail-unit-tests] branch master updated: Harmonize attachment test values

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-unit-tests.git


The following commit(s) were added to refs/heads/master by this push:
     new f160aa8  Harmonize attachment test values
f160aa8 is described below

commit f160aa820d78162db064c99b284dbceb89e147e9
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Sat Aug 15 08:02:16 2020 +0200

    Harmonize attachment test values
    
    When a message has no attachments or fails to parse, it should always be
    a blank list in the tests.
---
 tests/test-parsing.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/test-parsing.py b/tests/test-parsing.py
index 7a9a6b2..c5054d0 100644
--- a/tests/test-parsing.py
+++ b/tests/test-parsing.py
@@ -42,7 +42,7 @@ def generate_specs(args):
                 'index': key,
                 'message-id': message.get('message-id', '').strip(),
                 'body_sha3_256': body_sha3_256,
-                'attachments': json['attachments'] if json else None,
+                'attachments': json['attachments'] if json else [],
             })
         items[mboxfile] = tests
     with open(args.generate, 'w') as f:
@@ -83,10 +83,12 @@ def run_tests(args):
                 errors += 1
                 sys.stderr.write("""[FAIL] index %u: \nExpected:\n%s\nGot:\n%s\n""" %
                                  (test['index'], test['body_sha3_256'], body_sha3_256))
-            if (json['attachments'] if json else None) != test['attachments']:
+            att = json['attachments'] if json else []
+            att_expected = test['attachments'] or []
+            if att != att_expected:
                 errors += 1
                 sys.stderr.write("""[FAIL] index %u: \nExpected:\n%s\nGot:\n%s\n""" %
-                                 (test['index'], test['attachments'], json['attachments'] if json else None))
+                                 (test['index'], att_expected, att))
             else:
                 print("[PASS] index %u" % (test['index']))
     print("[DONE] %u tests run, %u failed." % (tests_run, errors))