Patchwork [2,of,3] test-manifest: make manifesttest a base class that is extended

login
register
mail settings
Submitter Drew Gottlieb
Date April 8, 2015, 12:17 a.m.
Message ID <d883ac09e0c528a731be.1428452275@waste.org>
Download mbox | patch
Permalink /patch/8556/
State Accepted
Headers show

Comments

Drew Gottlieb - April 8, 2015, 12:17 a.m.
# HG changeset patch
# User Drew Gottlieb <drgott@google.com>
# Date 1428444979 25200
#      Tue Apr 07 15:16:19 2015 -0700
# Node ID d883ac09e0c528a731be28cc760e894edf85528d
# Parent  b457b55e07aae93f13bc2053fd082dfe1bbafa1c
test-manifest: make manifesttest a base class that is extended

The implementation of the testmanifest test case is moved to a new base class,
which is then extended to make the testmanifest. And instead of testmanifest,
the subclass is named testmanifestdict because, well, that's what it's testing.

This refactoring makes it possible to create alternate versions of what was
formerly testmanifest, improving test coverage of different manifestdict
implementations.

Patch

diff --git a/tests/test-manifest.py b/tests/test-manifest.py
--- a/tests/test-manifest.py
+++ b/tests/test-manifest.py
@@ -95,9 +95,9 @@ 
                    itertools.cycle((HASH_1, HASH_2)),
                    itertools.cycle(('', 'x', 'l')))))
 
-class testmanifest(unittest.TestCase):
+class basemanifesttests(object):
     def parsemanifest(self, text):
-        return manifestmod.manifestdict(text)
+        raise NotImplementedError('parsemanifest not implemented by test case')
 
     def assertIn(self, thing, container, msg=None):
         # assertIn new in 2.7, use it if available, otherwise polyfill
@@ -456,5 +456,9 @@ 
                 ['a/b/c/bar.txt', 'a/b/c/foo.txt', 'a/b/d/ten.txt'],
                 m2.keys())
 
+class testmanifestdict(unittest.TestCase, basemanifesttests):
+    def parsemanifest(self, text):
+        return manifestmod.manifestdict(text)
+
 if __name__ == '__main__':
     silenttestrunner.main(__name__)