[PATCH] Improve parse changes tests
Hi,
Attached is the following:
commit 88d460407bfbf9c0fb9b36451c585b5a5d8c19f2
Author: Chris Lamb <lamby@debian.org>
Date: Mon Aug 24 16:18:57 2015 +0200
tests/test_parse_changes.py: Actually set dsc_file=1 when testing
.dsc
Signed-off-by: Chris Lamb <lamby@debian.org>
tests/test_parse_changes.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
commit e173647690a5e0779813b7d6ef82bde6a16fcf5c
Author: Chris Lamb <lamby@debian.org>
Date: Mon Aug 24 15:56:18 2015 +0200
tests/test_parse_changes.py: Rewrite loose and
difficult-to-use-correctly assertFails
Signed-off-by: Chris Lamb <lamby@debian.org>
tests/test_parse_changes.py | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
commit 4de9caeac056ae00c1905d430a464ae63888e3dc
Author: Chris Lamb <lamby@debian.org>
Date: Mon Aug 24 14:59:09 2015 +0200
tests/test_parse_changes.py: Actually use the blank file test
fixture
Was added in 47955ee9a5730c81b21ca9f31da4c176a82bcdc4 but never
actually
used.
Signed-off-by: Chris Lamb <lamby@debian.org>
tests/test_parse_changes.py | 5 +++++
1 file changed, 5 insertions(+)
commit 09a0b92396ac9b32ef2bf816614821d46f2da82b
Author: Chris Lamb <lamby@debian.org>
Date: Mon Aug 24 15:25:52 2015 +0200
tests/test_parse_changes.py: Test that an contentless .dsc fails
correctly
tests/fixtures/dsc/8.dsc | 11 +++++++++++
tests/test_parse_changes.py | 5 +++++
2 files changed, 16 insertions(+)
commit 7a9f450509f8a9071fe6c291e9bd5b7b18b565ff
Author: Chris Lamb <lamby@debian.org>
Date: Mon Aug 24 15:55:44 2015 +0200
tests/test_parse_changes.py: Move test to ParseDscTestCase as we
call with dsc_file=1
Signed-off-by: Chris Lamb <lamby@debian.org>
tests/fixtures/changes/two-beginnings.changes | 25
-------------------------
tests/fixtures/dsc/9.dsc | 25
+++++++++++++++++++++++++
tests/test_parse_changes.py | 10 +++++-----
3 files changed, 30 insertions(+), 30 deletions(-)
You could also merge from the "improve-parse-changes-tests-796787"
branch
of https://github.com/lamby/dak if that's more convenient.
Regards,
--
,''`.
: :' : Chris Lamb
`. `'` lamby@debian.org / chris-lamb.co.uk
`-
From 7a9f450509f8a9071fe6c291e9bd5b7b18b565ff Mon Sep 17 00:00:00 2001
From: Chris Lamb <lamby@debian.org>
Date: Mon, 24 Aug 2015 15:55:44 +0200
Subject: [PATCH 5/5] tests/test_parse_changes.py: Move test to
ParseDscTestCase as we call with dsc_file=1
Signed-off-by: Chris Lamb <lamby@debian.org>
---
tests/fixtures/changes/two-beginnings.changes | 25 -------------------------
tests/fixtures/dsc/9.dsc | 25 +++++++++++++++++++++++++
tests/test_parse_changes.py | 10 +++++-----
3 files changed, 30 insertions(+), 30 deletions(-)
delete mode 100644 tests/fixtures/changes/two-beginnings.changes
create mode 100644 tests/fixtures/dsc/9.dsc
diff --git a/tests/fixtures/changes/two-beginnings.changes b/tests/fixtures/changes/two-beginnings.changes
deleted file mode 100644
index 33fc072..0000000
--- a/tests/fixtures/changes/two-beginnings.changes
+++ /dev/null
@@ -1,25 +0,0 @@
------BEGIN PGP SIGNED MESSAGE OR SO-----
-Hash: SHA512
-
-This: is a bug.
------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA512
-
-Question: Is this a bug?
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.11 (GNU/Linux)
-
-iQIcBAEBCgAGBQJN1s1eAAoJEIATJTTdNH3Is4IP/3ppCve+jzobPjacyqYGyAec
-Op2rnYkQulfln1tyaxr8A40MHSWUly1kFebPgO3XNgAQ8mIh7FCeL7tSsaDnrBwq
-v/S/6JK1ZGCSuL6dleoqxoBgViJWQEvd297zAe0CzIdJ+JYgTPxX5cHh4E23rWmG
-zG9ct3v+5J4mSeEGksZPn8/YalnWRwb72hj/0WTagA2SY89TVZ9onT6p8ftWf6aO
-ODXDtclP56GixfnA3jR3reKI5/aLHXSLSYWGDOyEXffr0NoFvgtbsO4Y0FF2+Np3
-MpmJitoIRuJWk3zInYt0GeJskhEbvuF5Fnhiqrg43W5tFxB8pz5QHpDa/oq8Gfea
-MU/2p6FHA12nwD7CVdKWv/ra3nAWcJPqqfV//xgnZaBdS7d4G+3+tMFFYk8sWqc1
-JphkXJ9M8eX67oEuKgwhwHGV/wGu96nkTergnvlqpxk6uesfnsy0ixXX0UgLzwEZ
-ty1sZcCgq8dhdnEatkvRy2M13pS8S9iONmrowAck15YZuHcudBmvh5PFeNbpldmM
-ABLFApnjtD3DljzrjBgnHQS5UHDzDhDiEEAiQrUM3nu/CNi6UPoxasGszJK8W0iV
-MQmYVybk2L2lVV3b1qXURMyaFRcmVnLBNad/IiCbQiWTUCwg8zxzJoty1+f7+EDa
-rPpj3R0qGxz01UsVtS3W
-=/dES
------END PGP SIGNATURE-----
diff --git a/tests/fixtures/dsc/9.dsc b/tests/fixtures/dsc/9.dsc
new file mode 100644
index 0000000..33fc072
--- /dev/null
+++ b/tests/fixtures/dsc/9.dsc
@@ -0,0 +1,25 @@
+-----BEGIN PGP SIGNED MESSAGE OR SO-----
+Hash: SHA512
+
+This: is a bug.
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA512
+
+Question: Is this a bug?
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.11 (GNU/Linux)
+
+iQIcBAEBCgAGBQJN1s1eAAoJEIATJTTdNH3Is4IP/3ppCve+jzobPjacyqYGyAec
+Op2rnYkQulfln1tyaxr8A40MHSWUly1kFebPgO3XNgAQ8mIh7FCeL7tSsaDnrBwq
+v/S/6JK1ZGCSuL6dleoqxoBgViJWQEvd297zAe0CzIdJ+JYgTPxX5cHh4E23rWmG
+zG9ct3v+5J4mSeEGksZPn8/YalnWRwb72hj/0WTagA2SY89TVZ9onT6p8ftWf6aO
+ODXDtclP56GixfnA3jR3reKI5/aLHXSLSYWGDOyEXffr0NoFvgtbsO4Y0FF2+Np3
+MpmJitoIRuJWk3zInYt0GeJskhEbvuF5Fnhiqrg43W5tFxB8pz5QHpDa/oq8Gfea
+MU/2p6FHA12nwD7CVdKWv/ra3nAWcJPqqfV//xgnZaBdS7d4G+3+tMFFYk8sWqc1
+JphkXJ9M8eX67oEuKgwhwHGV/wGu96nkTergnvlqpxk6uesfnsy0ixXX0UgLzwEZ
+ty1sZcCgq8dhdnEatkvRy2M13pS8S9iONmrowAck15YZuHcudBmvh5PFeNbpldmM
+ABLFApnjtD3DljzrjBgnHQS5UHDzDhDiEEAiQrUM3nu/CNi6UPoxasGszJK8W0iV
+MQmYVybk2L2lVV3b1qXURMyaFRcmVnLBNad/IiCbQiWTUCwg8zxzJoty1+f7+EDa
+rPpj3R0qGxz01UsVtS3W
+=/dES
+-----END PGP SIGNATURE-----
diff --git a/tests/test_parse_changes.py b/tests/test_parse_changes.py
index ff48374..c7193db 100755
--- a/tests/test_parse_changes.py
+++ b/tests/test_parse_changes.py
@@ -55,6 +55,11 @@ class ParseDscTestCase(ParseChangesTestCase):
with self.assertRaisesRegexp(ParseChangesError, "Empty changes"):
self.assertParse('dsc/8.dsc', -1, 1)
+ def test_9(self):
+ changes = self.assertParse('dsc/9.dsc', -1, 1)
+ self.assert_(changes['question'] == 'Is this a bug?')
+ self.failIf(changes.get('this'))
+
class ParseChangesTestCase(ParseChangesTestCase):
def test_1(self):
# Empty changes
@@ -77,10 +82,5 @@ class ParseChangesTestCase(ParseChangesTestCase):
)
self.failIf(changes.get('you'))
- def test_4(self):
- changes = self.assertParse('changes/two-beginnings.changes', -1, 1)
- self.assert_(changes['question'] == 'Is this a bug?')
- self.failIf(changes.get('this'))
-
if __name__ == '__main__':
unittest.main()
--
2.5.1
From 09a0b92396ac9b32ef2bf816614821d46f2da82b Mon Sep 17 00:00:00 2001
From: Chris Lamb <lamby@debian.org>
Date: Mon, 24 Aug 2015 15:25:52 +0200
Subject: [PATCH 4/5] tests/test_parse_changes.py: Test that an contentless
.dsc fails correctly
---
tests/fixtures/dsc/8.dsc | 11 +++++++++++
tests/test_parse_changes.py | 5 +++++
2 files changed, 16 insertions(+)
create mode 100644 tests/fixtures/dsc/8.dsc
diff --git a/tests/fixtures/dsc/8.dsc b/tests/fixtures/dsc/8.dsc
new file mode 100644
index 0000000..92f3c52
--- /dev/null
+++ b/tests/fixtures/dsc/8.dsc
@@ -0,0 +1,11 @@
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.0.2 (GNU/Linux)
+Comment: For info see http://www.gnupg.org
+
+iD8DBQE5j091iPgEjVqvb1kRAvFtAJ0asUAaac6ebfR3YeaH16HjL7F3GwCfV+AQ
+rhYnRmVuNMa8oYSvL4hl/Yw=
+=EFAA
+-----END PGP SIGNATURE-----
diff --git a/tests/test_parse_changes.py b/tests/test_parse_changes.py
index 5f6d49a..ff48374 100755
--- a/tests/test_parse_changes.py
+++ b/tests/test_parse_changes.py
@@ -50,6 +50,11 @@ class ParseDscTestCase(ParseChangesTestCase):
with self.assertRaises(GpgException):
self.assertParse('dsc/7.dsc', -1, 1)
+ def test_8(self):
+ # No armored contents
+ with self.assertRaisesRegexp(ParseChangesError, "Empty changes"):
+ self.assertParse('dsc/8.dsc', -1, 1)
+
class ParseChangesTestCase(ParseChangesTestCase):
def test_1(self):
# Empty changes
--
2.5.1
From 4de9caeac056ae00c1905d430a464ae63888e3dc Mon Sep 17 00:00:00 2001
From: Chris Lamb <lamby@debian.org>
Date: Mon, 24 Aug 2015 14:59:09 +0200
Subject: [PATCH 3/5] tests/test_parse_changes.py: Actually use the blank file
test fixture
Was added in 47955ee9a5730c81b21ca9f31da4c176a82bcdc4 but never actually
used.
Signed-off-by: Chris Lamb <lamby@debian.org>
---
tests/test_parse_changes.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tests/test_parse_changes.py b/tests/test_parse_changes.py
index 2a66f83..5f6d49a 100755
--- a/tests/test_parse_changes.py
+++ b/tests/test_parse_changes.py
@@ -45,6 +45,11 @@ class ParseDscTestCase(ParseChangesTestCase):
# Extra blank line after signature header
self.assertParse('dsc/6.dsc', -1, 1)
+ def test_7(self):
+ # Blank file is an invalid armored GPG file
+ with self.assertRaises(GpgException):
+ self.assertParse('dsc/7.dsc', -1, 1)
+
class ParseChangesTestCase(ParseChangesTestCase):
def test_1(self):
# Empty changes
--
2.5.1
From e173647690a5e0779813b7d6ef82bde6a16fcf5c Mon Sep 17 00:00:00 2001
From: Chris Lamb <lamby@debian.org>
Date: Mon, 24 Aug 2015 15:56:18 +0200
Subject: [PATCH 2/5] tests/test_parse_changes.py: Rewrite loose and
difficult-to-use-correctly assertFails
Signed-off-by: Chris Lamb <lamby@debian.org>
---
tests/test_parse_changes.py | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/tests/test_parse_changes.py b/tests/test_parse_changes.py
index 50301f4..2a66f83 100755
--- a/tests/test_parse_changes.py
+++ b/tests/test_parse_changes.py
@@ -12,18 +12,6 @@ class ParseChangesTestCase(DakTestCase):
def assertParse(self, filename, *args):
return parse_changes(fixture(filename), *args)
- def assertFails(self, filename, line=None, *args):
- try:
- self.assertParse(filename, *args)
- self.fail('%s was not recognised as invalid' % filename)
- except ParseChangesError:
- pass
- except GpgException:
- pass
- except InvalidDscError as actual_line:
- if line is not None:
- assertEqual(actual_line, line)
-
class ParseDscTestCase(ParseChangesTestCase):
def test_1(self):
self.assertParse('dsc/1.dsc', -1, 1)
@@ -46,7 +34,8 @@ class ParseDscTestCase(ParseChangesTestCase):
def test_4(self):
# No blank lines at all
- self.assertFails('dsc/4.dsc', -1, 1, 1)
+ with self.assertRaises(GpgException):
+ self.assertParse('dsc/4.dsc', -1, 1)
def test_5(self):
# Extra blank line before signature body
@@ -59,7 +48,8 @@ class ParseDscTestCase(ParseChangesTestCase):
class ParseChangesTestCase(ParseChangesTestCase):
def test_1(self):
# Empty changes
- self.assertFails('changes/1.changes', 5, -1)
+ with self.assertRaises(GpgException):
+ self.assertParse('changes/1.changes', 1)
def test_2(self):
changes = self.assertParse('changes/2.changes', -1)
--
2.5.1
From 88d460407bfbf9c0fb9b36451c585b5a5d8c19f2 Mon Sep 17 00:00:00 2001
From: Chris Lamb <lamby@debian.org>
Date: Mon, 24 Aug 2015 16:18:57 +0200
Subject: [PATCH 1/5] tests/test_parse_changes.py: Actually set dsc_file=1 when
testing .dsc
Signed-off-by: Chris Lamb <lamby@debian.org>
---
tests/test_parse_changes.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/test_parse_changes.py b/tests/test_parse_changes.py
index 20dab4b..50301f4 100755
--- a/tests/test_parse_changes.py
+++ b/tests/test_parse_changes.py
@@ -46,7 +46,7 @@ class ParseDscTestCase(ParseChangesTestCase):
def test_4(self):
# No blank lines at all
- self.assertFails('dsc/4.dsc', -1, 1)
+ self.assertFails('dsc/4.dsc', -1, 1, 1)
def test_5(self):
# Extra blank line before signature body
--
2.5.1
Reply to: