Skip to content

Commit

Permalink
Remove import hack laziness for TemporaryClangTestDir
Browse files Browse the repository at this point in the history
  • Loading branch information
puremourning committed Nov 1, 2017
1 parent 70ef933 commit 2471e31
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
5 changes: 2 additions & 3 deletions ycmd/tests/clang/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import json


from ycmd.tests.test_utils import TemporaryTestDir as TemporaryClangTestDir # noqa
from ycmd.utils import ToUnicode
from ycmd.tests.test_utils import ClearCompletionsCache, IsolatedApp, SetUpApp

Expand Down Expand Up @@ -95,11 +94,11 @@ def Wrapper( *args, **kwargs ):
def TemporaryClangProject( tmp_dir, compile_commands ):
"""Context manager to create a compilation database in a directory and delete
it when the test completes. |tmp_dir| is the directory in which to create the
database file (typically used in conjunction with |TemporaryClangTestDir|) and
database file (typically used in conjunction with |TemporaryTestDir|) and
|compile_commands| is a python object representing the compilation database.
e.g.:
with TemporaryClangTestDir() as tmp_dir:
with TemporaryTestDir() as tmp_dir:
database = [
{
'directory': os.path.join( tmp_dir, dir ),
Expand Down
8 changes: 4 additions & 4 deletions ycmd/tests/clang/debug_info_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
instance_of, matches_regexp )

from ycmd.tests.clang import ( IsolatedYcmd, PathToTestFile, SharedYcmd,
TemporaryClangTestDir, TemporaryClangProject )
from ycmd.tests.test_utils import BuildRequest
TemporaryClangProject )
from ycmd.tests.test_utils import BuildRequest, TemporaryTestDir


@SharedYcmd
Expand Down Expand Up @@ -124,7 +124,7 @@ def DebugInfo_FlagsWhenExtraConfNotLoadedAndNoCompilationDatabase_test(

@IsolatedYcmd()
def DebugInfo_FlagsWhenNoExtraConfAndCompilationDatabaseLoaded_test( app ):
with TemporaryClangTestDir() as tmp_dir:
with TemporaryTestDir() as tmp_dir:
compile_commands = [
{
'directory': tmp_dir,
Expand Down Expand Up @@ -159,7 +159,7 @@ def DebugInfo_FlagsWhenNoExtraConfAndCompilationDatabaseLoaded_test( app ):

@IsolatedYcmd()
def DebugInfo_FlagsWhenNoExtraConfAndInvalidCompilationDatabase_test( app ):
with TemporaryClangTestDir() as tmp_dir:
with TemporaryTestDir() as tmp_dir:
compile_commands = 'garbage'
with TemporaryClangProject( tmp_dir, compile_commands ):
request_data = BuildRequest(
Expand Down
20 changes: 10 additions & 10 deletions ycmd/tests/clang/flags_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
from ycmd.completers.cpp import flags
from mock import patch, MagicMock
from types import ModuleType
from ycmd.tests.test_utils import MacOnly
from ycmd.tests.test_utils import MacOnly, TemporaryTestDir
from ycmd.responses import NoExtraConfDetected
from ycmd.tests.clang import TemporaryClangProject, TemporaryClangTestDir
from ycmd.tests.clang import TemporaryClangProject

from hamcrest import assert_that, calling, contains, has_item, not_, raises

Expand Down Expand Up @@ -493,7 +493,7 @@ def Mac_SelectMacToolchain_CommandLineTools_test( *args ):


def CompilationDatabase_NoDatabase_test():
with TemporaryClangTestDir() as tmp_dir:
with TemporaryTestDir() as tmp_dir:
assert_that(
calling( flags.Flags().FlagsForFile ).with_args(
os.path.join( tmp_dir, 'test.cc' ) ),
Expand All @@ -502,15 +502,15 @@ def CompilationDatabase_NoDatabase_test():

def CompilationDatabase_FileNotInDatabase_test():
compile_commands = [ ]
with TemporaryClangTestDir() as tmp_dir:
with TemporaryTestDir() as tmp_dir:
with TemporaryClangProject( tmp_dir, compile_commands ):
eq_(
flags.Flags().FlagsForFile( os.path.join( tmp_dir, 'test.cc' ) ),
[] )


def CompilationDatabase_InvalidDatabase_test():
with TemporaryClangTestDir() as tmp_dir:
with TemporaryTestDir() as tmp_dir:
with TemporaryClangProject( tmp_dir, 'this is junk' ):
assert_that(
calling( flags.Flags().FlagsForFile ).with_args(
Expand All @@ -519,7 +519,7 @@ def CompilationDatabase_InvalidDatabase_test():


def CompilationDatabase_UseFlagsFromDatabase_test():
with TemporaryClangTestDir() as tmp_dir:
with TemporaryTestDir() as tmp_dir:
compile_commands = [
{
'directory': tmp_dir,
Expand All @@ -543,7 +543,7 @@ def CompilationDatabase_UseFlagsFromDatabase_test():


def CompilationDatabase_UseFlagsFromSameDir_test():
with TemporaryClangTestDir() as tmp_dir:
with TemporaryTestDir() as tmp_dir:
compile_commands = [
{
'directory': tmp_dir,
Expand Down Expand Up @@ -590,7 +590,7 @@ def CompilationDatabase_UseFlagsFromSameDir_test():


def CompilationDatabase_HeaderFileHeuristic_test():
with TemporaryClangTestDir() as tmp_dir:
with TemporaryTestDir() as tmp_dir:
compile_commands = [
{
'directory': tmp_dir,
Expand All @@ -614,7 +614,7 @@ def CompilationDatabase_HeaderFileHeuristic_test():


def CompilationDatabase_HeaderFileHeuristicNotFound_test():
with TemporaryClangTestDir() as tmp_dir:
with TemporaryTestDir() as tmp_dir:
compile_commands = [
{
'directory': tmp_dir,
Expand All @@ -634,7 +634,7 @@ def CompilationDatabase_HeaderFileHeuristicNotFound_test():


def CompilationDatabase_ExplicitHeaderFileEntry_test():
with TemporaryClangTestDir() as tmp_dir:
with TemporaryTestDir() as tmp_dir:
# Have an explicit header file entry which should take priority over the
# corresponding source file
compile_commands = [
Expand Down

0 comments on commit 2471e31

Please sign in to comment.