update hg integration test inheritance to allow type checking

Summary:
Python 3 type checking currently complains about most of our integration
testing since the tests use an `hg_test` decorator to inherit from the base
test class.  This prevents the type checker from being able to figure out this
inheritance.

This updates all of the test cases to explicitly derive from the test case base
class, rather than using the decorator to do so.  I also renamed the base test
case class to `EdenHgTestCase` to be slightly more succinct and to follow the
common pattern of calling `unittest.TestCase` subclasses `FooTestCase`

Reviewed By: bolinfest

Differential Revision: D6268258

fbshipit-source-id: 09eef2f8217932a6516f78d17dddcd35c83b73da
This commit is contained in:
Adam Simpkins 2017-11-07 18:47:42 -08:00 committed by Facebook Github Bot
parent 017f636ad3
commit c3ebc91fdc
24 changed files with 52 additions and 52 deletions

View File

@ -8,13 +8,13 @@
# of patent rights can be found in the PATENTS file in the same directory. # of patent rights can be found in the PATENTS file in the same directory.
import logging import logging
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
log = logging.getLogger('eden.test.absorb') log = logging.getLogger('eden.test.absorb')
@hg_test @hg_test
class AbsorbTest: class AbsorbTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file('readme.txt', 'readme\n') repo.write_file('readme.txt', 'readme\n')
repo.write_file('src/test.c', '''\ repo.write_file('src/test.c', '''\

View File

@ -7,14 +7,14 @@
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory. # of patent rights can be found in the PATENTS file in the same directory.
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
import os import os
import subprocess import subprocess
import unittest import unittest
@hg_test @hg_test
class AddTest: class AddTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file('rootfile.txt', '') repo.write_file('rootfile.txt', '')
repo.write_file('dir1/a.txt', 'original contents') repo.write_file('dir1/a.txt', 'original contents')

View File

@ -7,11 +7,11 @@
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory. # of patent rights can be found in the PATENTS file in the same directory.
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
@hg_test @hg_test
class BranchTest: class BranchTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file('a_file.txt', '') repo.write_file('a_file.txt', '')
repo.commit('first commit') repo.commit('first commit')

View File

@ -9,11 +9,11 @@
import os import os
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
@hg_test @hg_test
class CommitTest: class CommitTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file('hello.txt', 'hola') repo.write_file('hello.txt', 'hola')
repo.write_file('foo/bar.txt', 'test\n') repo.write_file('foo/bar.txt', 'test\n')

View File

@ -9,11 +9,11 @@
from textwrap import dedent from textwrap import dedent
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
@hg_test @hg_test
class CopyTest: class CopyTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file('hello.txt', 'hola') repo.write_file('hello.txt', 'hola')
repo.commit('Initial commit.\n') repo.commit('Initial commit.\n')

View File

@ -8,11 +8,11 @@
# of patent rights can be found in the PATENTS file in the same directory. # of patent rights can be found in the PATENTS file in the same directory.
from textwrap import dedent from textwrap import dedent
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
@hg_test @hg_test
class DebugHgDirstateTest: class DebugHgDirstateTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file('rootfile.txt', '') repo.write_file('rootfile.txt', '')
repo.commit('Initial commit.') repo.commit('Initial commit.')

View File

@ -7,12 +7,12 @@
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory. # of patent rights can be found in the PATENTS file in the same directory.
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
from textwrap import dedent from textwrap import dedent
@hg_test @hg_test
class DebugHgGetDirstateTupleTest: class DebugHgGetDirstateTupleTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file('hello', 'hola\n') repo.write_file('hello', 'hola\n')
repo.write_file('dir/file', 'blah\n') repo.write_file('dir/file', 'blah\n')

View File

@ -7,12 +7,12 @@
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory. # of patent rights can be found in the PATENTS file in the same directory.
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
import re import re
@hg_test @hg_test
class DiffTest: class DiffTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file('rootfile.txt', '') repo.write_file('rootfile.txt', '')
repo.write_file('dir1/a.txt', 'original contents\n') repo.write_file('dir1/a.txt', 'original contents\n')

View File

@ -9,12 +9,12 @@
import os import os
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
from ..lib import hgrepo from ..lib import hgrepo
@hg_test @hg_test
class GraftTest: class GraftTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file('first.txt', '1') repo.write_file('first.txt', '1')
self.commit1 = repo.commit('Initial commit\n') self.commit1 = repo.commit('Initial commit\n')

View File

@ -8,12 +8,12 @@
# of patent rights can be found in the PATENTS file in the same directory. # of patent rights can be found in the PATENTS file in the same directory.
from textwrap import dedent from textwrap import dedent
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
from ..lib import hgrepo from ..lib import hgrepo
@hg_test @hg_test
class GrepTest: class GrepTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file( repo.write_file(
'file_in_root.txt', '\n'.join(['apple', ' banana', 'cat']) 'file_in_root.txt', '\n'.join(['apple', ' banana', 'cat'])

View File

@ -10,13 +10,13 @@
import os import os
from textwrap import dedent from textwrap import dedent
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
from .lib.histedit_command import HisteditCommand from .lib.histedit_command import HisteditCommand
from ..lib import hgrepo from ..lib import hgrepo
@hg_test @hg_test
class HisteditTest: class HisteditTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file('first', '') repo.write_file('first', '')
self._commit1 = repo.commit('first commit') self._commit1 = repo.commit('first commit')

View File

@ -48,7 +48,7 @@ POST_CLONE = _find_post_clone()
EDEN_EXT_DIR = _eden_ext_dir() EDEN_EXT_DIR = _eden_ext_dir()
class HgExtensionTestBase(testcase.EdenTestCase): class EdenHgTestCase(testcase.EdenTestCase):
''' '''
A test case class for integration tests that exercise mercurial commands A test case class for integration tests that exercise mercurial commands
inside an eden client. inside an eden client.
@ -278,7 +278,7 @@ def _replicate_hg_test(test_class):
} }
for name, config_fn in configs.items(): for name, config_fn in configs.items():
class HgTestVariant(test_class, HgExtensionTestBase): class HgTestVariant(test_class):
apply_hg_config_variant = config_fn apply_hg_config_variant = config_fn
yield name, HgTestVariant yield name, HgTestVariant

View File

@ -7,7 +7,7 @@
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory. # of patent rights can be found in the PATENTS file in the same directory.
from .hg_extension_test_base import HgExtensionTestBase from .hg_extension_test_base import EdenHgTestCase
import os import os
@ -29,7 +29,7 @@ class HisteditCommand:
def stop(self, commit_hash: str) -> None: def stop(self, commit_hash: str) -> None:
self._actions.append('stop %s\n' % commit_hash) self._actions.append('stop %s\n' % commit_hash)
def run(self, test_base: HgExtensionTestBase, ancestor: str = None) -> None: def run(self, test_base: EdenHgTestCase, ancestor: str = None) -> None:
commands_file = os.path.join(test_base.tmp_dir, 'histedit_commands.txt') commands_file = os.path.join(test_base.tmp_dir, 'histedit_commands.txt')
with open(commands_file, 'w') as f: with open(commands_file, 'w') as f:
[f.write(action) for action in self._actions] [f.write(action) for action in self._actions]

View File

@ -7,11 +7,11 @@
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory. # of patent rights can be found in the PATENTS file in the same directory.
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
@hg_test @hg_test
class MergeTest: class MergeTest(EdenHgTestCase):
'''Note that Mercurial has a number of built-in merge tools: '''Note that Mercurial has a number of built-in merge tools:
https://www.mercurial-scm.org/repo/hg/help/merge-tools https://www.mercurial-scm.org/repo/hg/help/merge-tools
''' '''

View File

@ -10,11 +10,11 @@
import os import os
from textwrap import dedent from textwrap import dedent
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
@hg_test @hg_test
class MoveTest: class MoveTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file('hello.txt', 'hola') repo.write_file('hello.txt', 'hola')
repo.commit('Initial commit.\n') repo.commit('Initial commit.\n')

View File

@ -8,12 +8,12 @@
# of patent rights can be found in the PATENTS file in the same directory. # of patent rights can be found in the PATENTS file in the same directory.
import os import os
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
from ..lib import eden_server_inspector from eden.integration.lib import eden_server_inspector
@hg_test @hg_test
class RebaseTest: class RebaseTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.mkdir('numbers') repo.mkdir('numbers')
repo.write_file('numbers/README', 'this will have two directories') repo.write_file('numbers/README', 'this will have two directories')

View File

@ -7,11 +7,11 @@
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory. # of patent rights can be found in the PATENTS file in the same directory.
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
@hg_test @hg_test
class RevertTest: class RevertTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file('hello.txt', 'hola') repo.write_file('hello.txt', 'hola')
repo.commit('Initial commit.\n') repo.commit('Initial commit.\n')

View File

@ -9,12 +9,12 @@
import os import os
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
from ..lib import hgrepo from ..lib import hgrepo
@hg_test @hg_test
class RmTest: class RmTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file('apple', '') repo.write_file('apple', '')
repo.write_file('banana', '') repo.write_file('banana', '')

View File

@ -7,12 +7,12 @@
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory. # of patent rights can be found in the PATENTS file in the same directory.
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
from ..lib import hgrepo from ..lib import hgrepo
@hg_test @hg_test
class RollbackTest: class RollbackTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file('first', '') repo.write_file('first', '')
self._commit1 = repo.commit('first commit') self._commit1 = repo.commit('first commit')

View File

@ -8,12 +8,12 @@
# of patent rights can be found in the PATENTS file in the same directory. # of patent rights can be found in the PATENTS file in the same directory.
from textwrap import dedent from textwrap import dedent
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
from ..lib import hgrepo from ..lib import hgrepo
@hg_test @hg_test
class SplitTest: class SplitTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file('letters', 'a\nb\nc\n') repo.write_file('letters', 'a\nb\nc\n')
repo.write_file('numbers', '1\n2\n3\n') repo.write_file('numbers', '1\n2\n3\n')

View File

@ -11,12 +11,12 @@ import logging
import os import os
from typing import Callable, Dict, List, Optional from typing import Callable, Dict, List, Optional
from eden.integration.lib.repobase import Repository from eden.integration.lib.hgrepo import HgRepository
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
@hg_test @hg_test
class StatusDeadlockTest: class StatusDeadlockTest(EdenHgTestCase):
""" """
Test running an "hg status" command that needs to import many directories Test running an "hg status" command that needs to import many directories
and .gitignore files. and .gitignore files.
@ -34,7 +34,7 @@ class StatusDeadlockTest:
levels['eden.fs.store.hg'] = 'DBG9' levels['eden.fs.store.hg'] = 'DBG9'
return levels return levels
def populate_backing_repo(self, repo: Repository) -> None: def populate_backing_repo(self, repo: HgRepository) -> None:
logging.debug('== populate_backing_repo') logging.debug('== populate_backing_repo')
# By default repo.write_file() also calls "hg add" on the path. # By default repo.write_file() also calls "hg add" on the path.
@ -79,7 +79,7 @@ class StatusDeadlockTest:
self.commit2 = repo.commit('Initial commit.') self.commit2 = repo.commit('Initial commit.')
logging.debug('== created second commit') logging.debug('== created second commit')
def _hg_add_many(self, repo: Repository, paths: List[str]) -> None: def _hg_add_many(self, repo: HgRepository, paths: List[str]) -> None:
# Call "hg add" with at most chunk_size files at a time # Call "hg add" with at most chunk_size files at a time
chunk_size = 250 chunk_size = 250
for n in range(0, len(paths), chunk_size): for n in range(0, len(paths), chunk_size):

View File

@ -7,11 +7,11 @@
# LICENSE file in the root directory of this source tree. An additional grant # LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory. # of patent rights can be found in the PATENTS file in the same directory.
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
@hg_test @hg_test
class StatusTest: class StatusTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file('hello.txt', 'hola') repo.write_file('hello.txt', 'hola')
repo.commit('Initial commit.') repo.commit('Initial commit.')

View File

@ -10,11 +10,11 @@
import logging import logging
import os import os
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
@hg_test @hg_test
class UndoTest: class UndoTest(EdenHgTestCase):
def populate_backing_repo(self, repo): def populate_backing_repo(self, repo):
repo.write_file('src/common/foo/test.txt', 'testing\n') repo.write_file('src/common/foo/test.txt', 'testing\n')
self.commit1 = repo.commit('Initial commit.') self.commit1 = repo.commit('Initial commit.')

View File

@ -9,12 +9,12 @@
import os import os
from ..lib import hgrepo from ..lib import hgrepo
from .lib.hg_extension_test_base import hg_test from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
from textwrap import dedent from textwrap import dedent
@hg_test @hg_test
class UpdateTest: class UpdateTest(EdenHgTestCase):
def edenfs_logging_settings(self): def edenfs_logging_settings(self):
return { return {
'eden.fs.inodes.TreeInode': 'DBG5', 'eden.fs.inodes.TreeInode': 'DBG5',