Chromium Code Reviews| Index: testing_support/git/unittest_helpers.py |
| diff --git a/testing_support/git/unittest_helpers.py b/testing_support/git/unittest_helpers.py |
| index 94a720efa1e5537aafc998b8b94970d1c97fe261..e8e498ff92a4c8cd73201aab0110faec0b9e35f7 100644 |
| --- a/testing_support/git/unittest_helpers.py |
| +++ b/testing_support/git/unittest_helpers.py |
| @@ -8,7 +8,7 @@ from testing_support.git.repo import GitRepo |
| from testing_support.git.schema import GitRepoSchema |
| -class GitRepoSchemaTestBase(auto_stub.TestCase): |
| +class GitRepoTestBase(auto_stub.TestCase): |
| """A TestCase with a built-in GitRepoSchema. |
| Expects a class variable REPO_SCHEMA to be a GitRepoSchema string in the form |
| @@ -19,62 +19,43 @@ class GitRepoSchemaTestBase(auto_stub.TestCase): |
| You probably will end up using either GitRepoReadOnlyTestBase or |
| GitRepoReadWriteTestBase for real tests. |
| - """ |
| - REPO_SCHEMA = None |
| - |
| - @classmethod |
| - def getRepoContent(cls, commit): |
| - return getattr(cls, 'COMMIT_%s' % commit, None) |
| - |
| - @classmethod |
| - def setUpClass(cls): |
| - super(GitRepoSchemaTestBase, cls).setUpClass() |
| - assert cls.REPO_SCHEMA is not None |
| - cls.r_schema = GitRepoSchema(cls.REPO_SCHEMA, cls.getRepoContent) |
| - |
| -class GitRepoReadOnlyTestBase(GitRepoSchemaTestBase): |
| - """Injects a GitRepo object given the schema and content from |
| + Injects a GitRepo object given the schema and content from |
| GitRepoSchemaTestBase into TestCase classes which subclass this. |
|
Vadim Sh.
2014/08/17 04:39:59
GitRepoSchemaTestBase?
iannucci
2014/08/17 08:47:04
Fixed this whole docstring
|
| - This GitRepo will appear as self.repo, and will be deleted and recreated once |
| - for the duration of all the tests in the subclass. |
| + This GitRepo will appear as self.repo, and will be deleted and recreated for |
| + each test function in the subclass. |
| """ |
| REPO_SCHEMA = None |
| @classmethod |
| - def setUpClass(cls): |
| - super(GitRepoReadOnlyTestBase, cls).setUpClass() |
| - assert cls.REPO_SCHEMA is not None |
| - cls.repo = GitRepo(cls.r_schema) |
| - |
| - def setUp(self): |
| - self.repo.git('checkout', '-f', self.repo.last_commit) |
| - |
| - @classmethod |
| - def tearDownClass(cls): |
| - cls.repo.nuke() |
| - super(GitRepoReadOnlyTestBase, cls).tearDownClass() |
| - |
| - |
| -class GitRepoReadWriteTestBase(GitRepoSchemaTestBase): |
| - """Injects a GitRepo object given the schema and content from |
| - GitRepoSchemaTestBase into TestCase classes which subclass this. |
| + def getRepoContent(cls, commit): |
| + return getattr(cls, 'COMMIT_%s' % commit, None) |
| - This GitRepo will appear as self.repo, and will be deleted and recreated for |
| - each test function in the subclass. |
| - """ |
| - REPO_SCHEMA = None |
| + def assertSchema(self, schema_string): |
| + self.assertEqual(GitRepoSchema(schema_string).simple_graph(), |
| + self.repo.to_schema().simple_graph()) |
| def setUp(self): |
| - super(GitRepoReadWriteTestBase, self).setUp() |
| + super(GitRepoTestBase, self).setUp() |
| + assert self.REPO_SCHEMA is not None |
| + # TODO(iannucci): r_schema could be established at class-load time, using |
| + # a metaclass. This would enable us to only parse the schema once per |
| + # derived test case class. |
| + self.r_schema = GitRepoSchema(self.REPO_SCHEMA, self.getRepoContent) |
|
Vadim Sh.
2014/08/17 04:39:59
is r_schema used outside of setUp here?
iannucci
2014/08/17 08:47:04
It can be/is accessed by the tests
|
| self.repo = GitRepo(self.r_schema) |
| + self.repo.git('checkout', '-f', self.repo.last_commit) |
| def tearDown(self): |
| self.repo.nuke() |
|
Vadim Sh.
2014/08/17 04:39:59
try:
...
finally:
super(GitRepoTestBase, self)
iannucci
2014/08/17 08:47:04
Fair enough. I haven't seen it blow up in practice
|
| - super(GitRepoReadWriteTestBase, self).tearDown() |
| + super(GitRepoTestBase, self).tearDown() |
| - def assertSchema(self, schema_string): |
| - self.assertEqual(GitRepoSchema(schema_string).simple_graph(), |
| - self.repo.to_schema().simple_graph()) |
| +# The read-only version used to set up and tear down repo on a setUpClass basis, |
| +# and the read-write version used to do it on a setUp basis. This is no longer |
| +# the case. Keep the names around, but they're deprecated. |
| +GitRepoReadWriteTestBase = GitRepoTestBase |
|
Vadim Sh.
2014/08/17 04:39:59
I assume you'll commit this, roll deps, get rid of
iannucci
2014/08/17 08:47:04
yep
|
| +GitRepoReadOnlyTestBase = GitRepoTestBase |
| + |
| +# Additionally, there was a schema-only version, but it was pretty useless |
| +GitRepoSchemaTestBase = GitRepoTestBase |