コード例 #1
0
ファイル: subcommands_test.py プロジェクト: Valloric/ycmd
def Subcommands_FixIt_test( app ):
  RunTest( app, {
    'description': 'FixIt works on a non-existing method',
    'request': {
      'command': 'FixIt',
      'line_num': 35,
      'column_num': 12,
      'filepath': PathToTestFile( 'test.ts' ),
    },
    'expect': {
      'response': requests.codes.ok,
      'data': has_entries( {
        'fixits': contains_inanyorder(
          has_entries( {
            'text': "Declare method 'nonExistingMethod'",
            'chunks': contains(
              ChunkMatcher(
                matches_regexp(
                  '^\r?\n'
                  '    nonExistingMethod\\(\\): any {\r?\n'
                  '        throw new Error\\("Method not implemented."\\);\r?\n'
                  '    }$',
                ),
                LocationMatcher( PathToTestFile( 'test.ts' ), 25, 12 ),
                LocationMatcher( PathToTestFile( 'test.ts' ), 25, 12 ) )
            ),
            'location': LocationMatcher( PathToTestFile( 'test.ts' ), 35, 12 )
          } ),
          has_entries( {
            'text': "Declare property 'nonExistingMethod'",
            'chunks': contains(
              ChunkMatcher(
                matches_regexp( '^\r?\n'
                                '    nonExistingMethod: any;$' ),
                LocationMatcher( PathToTestFile( 'test.ts' ), 25, 12 ),
                LocationMatcher( PathToTestFile( 'test.ts' ), 25, 12 ) )
            ),
            'location': LocationMatcher( PathToTestFile( 'test.ts' ), 35, 12 )
          } ),
          has_entries( {
            'text': "Add index signature for property 'nonExistingMethod'",
            'chunks': contains(
              ChunkMatcher(
                matches_regexp( '^\r?\n'
                                '    \\[x: string\\]: any;$' ),
                LocationMatcher( PathToTestFile( 'test.ts' ), 25, 12 ),
                LocationMatcher( PathToTestFile( 'test.ts' ), 25, 12 ) )
            ),
            'location': LocationMatcher( PathToTestFile( 'test.ts' ), 35, 12 )
          } )
        )
      } )
    }
  } )
コード例 #2
0
def DebugInfo_FlagsWhenGlobalExtraConfAndNoCompilationDatabase_test(app):
    request_data = BuildRequest(filepath=PathToTestFile('basic.cpp'),
                                filetype='cpp')
    assert_that(
        app.post_json('/debug_info', request_data).json,
        has_entry(
            'completer',
            has_entries({
                'name':
                'C-family',
                'servers':
                empty(),
                'items':
                contains(
                    has_entries({
                        'key': 'compilation database path',
                        'value': 'None'
                    }),
                    has_entries({
                        'key':
                        'flags',
                        'value':
                        matches_regexp("\[u?'-x', u?'c\+\+', .*\]")
                    }),
                    has_entries({
                        'key': 'translation unit',
                        'value': PathToTestFile('basic.cpp')
                    }))
            })))
コード例 #3
0
ファイル: subcommands_test.py プロジェクト: mjbrownie/ycmd
def Subcommands_FixIt_test( app ):
  filepath = PathToTestFile( 'test.js' )
  RunTest( app, {
    'description': 'FixIt works on a non-existing method',
    'request': {
      'command': 'FixIt',
      'line_num': 32,
      'column_num': 19,
      'filepath': filepath,
    },
    'expect': {
      'response': requests.codes.ok,
      'data': has_entries( {
        'fixits': contains_inanyorder(
          has_entries( {
            'text': "Declare method 'nonExistingMethod'",
            'chunks': contains(
              ChunkMatcher(
                matches_regexp(
                  '^\r?\n'
                  '    nonExistingMethod\(\) {\r?\n'
                  '        throw new Error\("Method not implemented."\);\r?\n'
                  '    }$',
                ),
                LocationMatcher( filepath, 22, 12 ),
                LocationMatcher( filepath, 22, 12 ) )
            ),
            'location': LocationMatcher( filepath, 32, 19 )
          } )
        )
      } )
    }
  } )
コード例 #4
0
def YouCompleteMe_DebugInfo_ServerRunning_test( ycm ):
  dir_of_script = os.path.dirname( os.path.abspath( __file__ ) )
  buf_name = os.path.join( dir_of_script, 'testdata', 'test.cpp' )
  extra_conf = os.path.join( dir_of_script, 'testdata', '.ycm_extra_conf.py' )
  _LoadExtraConfFile( extra_conf )

  current_buffer = VimBuffer( buf_name, filetype='cpp' )
  with MockVimBuffers( [ current_buffer ], current_buffer ):
    assert_that(
      ycm.DebugInfo(),
      matches_regexp(
        'Client logfile: .+\n'
        'Server Python interpreter: .+\n'
        'Server Python version: .+\n'
        'Server has Clang support compiled in: '
        '(?P<CLANG>True)?(?(CLANG)|False)\n'
        'Clang version: .+\n'
        'Extra configuration file found and loaded\n'
        'Extra configuration path: .*testdata[/\\\\]\\.ycm_extra_conf\\.py\n'
        '(?(CLANG)C-family completer debug information:\n'
        '  Compilation database path: None\n'
        '  Flags: \\[u?\'_TEMP_FILE_\'.*\\]\n'
        '  Translation unit: .+\n)'
        'Server running at: .+\n'
        'Server process ID: \d+\n'
        'Server logfiles:\n'
        '  .+\n'
        '  .+' )
    )
コード例 #5
0
def Subcommands_FixIt_test( app ):
  filepath = PathToTestFile( 'test.js' )
  RunTest( app, {
    'description': 'FixIt works on a non-existing method',
    'request': {
      'command': 'FixIt',
      'line_num': 32,
      'column_num': 19,
      'filepath': filepath,
    },
    'expect': {
      'response': requests.codes.ok,
      'data': has_entries( {
        'fixits': contains_inanyorder(
          has_entries( {
            'text': "Declare method 'nonExistingMethod'",
            'chunks': contains(
              ChunkMatcher(
                matches_regexp(
                  '^\r?\n'
                  '    nonExistingMethod\(\) {\r?\n'
                  '        throw new Error\("Method not implemented."\);\r?\n'
                  '    }$',
                ),
                LocationMatcher( filepath, 22, 12 ),
                LocationMatcher( filepath, 22, 12 ) )
            ),
            'location': LocationMatcher( filepath, 32, 19 )
          } )
        )
      } )
    }
  } )
コード例 #6
0
ファイル: subcommands_test.py プロジェクト: mjbrownie/ycmd
def Subcommands_OrganizeImports_test( app ):
  filepath = PathToTestFile( 'imports.js' )
  RunTest( app, {
    'description': 'OrganizeImports removes unused imports, '
                   'coalesces imports from the same module, and sorts them',
    'request': {
      'command': 'OrganizeImports',
      'filepath': filepath,
    },
    'expect': {
      'response': requests.codes.ok,
      'data': has_entries( {
        'fixits': contains( has_entries( {
          'chunks': contains(
            ChunkMatcher(
              matches_regexp(
                'import \* as lib from "library";\r?\n'
                'import func, { func1, func2 } from "library";\r?\n' ),
              LocationMatcher( filepath,  1, 1 ),
              LocationMatcher( filepath,  2, 1 ) ),
            ChunkMatcher(
              '',
              LocationMatcher( filepath,  5, 1 ),
              LocationMatcher( filepath,  6, 1 ) ),
            ChunkMatcher(
              '',
              LocationMatcher( filepath,  9, 1 ),
              LocationMatcher( filepath, 10, 1 ) ),
          )
        } ) )
      } )
    }
  } )
コード例 #7
0
def DebugInfo_ProjectDirectory_test( app ):
  project_dir = PathToTestFile( 'td' )
  StartGoCompleterServerInDirectory( app, project_dir )
  assert_that(
    app.post_json( '/debug_info', BuildRequest( filetype = 'go' ) ).json,
    has_entry( 'completer', has_entries( {
      'name': 'Go',
      'servers': contains_exactly( has_entries( {
        'name': 'gopls',
        'is_running': instance_of( bool ),
        'executable': contains_exactly( instance_of( str ),
                                        instance_of( str ),
                                        instance_of( str ),
                                        instance_of( str ) ),
        'address': None,
        'port': None,
        'pid': instance_of( int ),
        'logfiles': contains_exactly( instance_of( str ) ),
        'extras': contains_exactly(
          has_entries( {
            'key': 'Server State',
            'value': instance_of( str ),
          } ),
          has_entries( {
            'key': 'Project Directory',
            'value': PathToTestFile(),
          } ),
          has_entries( {
            'key': 'Settings',
            'value': matches_regexp( '{\n  "hoverKind": "Structured"\n}' )
          } ),
        )
      } ) ),
    } ) )
  )
コード例 #8
0
ファイル: debug_info_test.py プロジェクト: CoderPad/ycmd
def DebugInfo_FlagsWhenNoExtraConfAndCompilationDatabaseLoaded_test( app ):
  with TemporaryTestDir() as tmp_dir:
    compile_commands = [
      {
        'directory': tmp_dir,
        'command': 'clang++ -I. -I/absolute/path -Wall',
        'file': os.path.join( tmp_dir, 'test.cc' ),
      },
    ]
    with TemporaryClangProject( tmp_dir, compile_commands ):
      request_data = BuildRequest(
        filepath = os.path.join( tmp_dir, 'test.cc' ),
        filetype = 'cpp' )

      assert_that(
        app.post_json( '/debug_info', request_data ).json,
        has_entry( 'completer', has_entries( {
          'name': 'C-family',
          'servers': empty(),
          'items': contains(
            has_entries( {
              'key': 'compilation database path',
              'value': instance_of( str )
            } ),
            has_entries( {
              'key': 'flags',
              'value': matches_regexp(
                  "\['clang\+\+', '-x', 'c\+\+', .*, '-Wall', .*\]" )
            } )
          )
        } ) )
      )
コード例 #9
0
def YouCompleteMe_DebugInfo_ServerRunning_test( ycm ):
  dir_of_script = os.path.dirname( os.path.abspath( __file__ ) )
  buf_name = os.path.join( dir_of_script, 'testdata', 'test.cpp' )
  extra_conf = os.path.join( dir_of_script, 'testdata', '.ycm_extra_conf.py' )
  _LoadExtraConfFile( extra_conf )

  current_buffer = VimBuffer( buf_name, filetype='cpp' )
  with MockVimBuffers( [ current_buffer ], current_buffer ):
    assert_that(
      ycm.DebugInfo(),
      matches_regexp(
        'Client logfile: .+\n'
        'Server Python interpreter: .+\n'
        'Server Python version: .+\n'
        'Server has Clang support compiled in: '
        '(?P<CLANG>True)?(?(CLANG)|False)\n'
        'Clang version: .+\n'
        'Extra configuration file found and loaded\n'
        'Extra configuration path: .*testdata[/\\\\]\\.ycm_extra_conf\\.py\n'
        '(?(CLANG)C-family completer debug information:\n'
        '  Compilation database path: None\n'
        '  Flags: \\[\'_TEMP_FILE_\'.*\\]\n)'
        'Server running at: .+\n'
        'Server process ID: \d+\n'
        'Server logfiles:\n'
        '  .+\n'
        '  .+' )
    )
コード例 #10
0
def YouCompleteMe_DebugInfo_ServerRunning_test( ycm ):
  dir_of_script = os.path.dirname( os.path.abspath( __file__ ) )
  buf_name = os.path.join( dir_of_script, 'testdata', 'test.cpp' )
  extra_conf = os.path.join( dir_of_script, 'testdata', '.ycm_extra_conf.py' )
  _LoadExtraConfFile( extra_conf )

  current_buffer = VimBuffer( buf_name, filetype = 'cpp' )
  with MockVimBuffers( [ current_buffer ], [ current_buffer ] ):
    assert_that(
      ycm.DebugInfo(),
      matches_regexp(
        'Client logfile: .+\n'
        'Server Python interpreter: .+\n'
        'Server Python version: .+\n'
        'Server has Clang support compiled in: (False|True)\n'
        'Clang version: .+\n'
        'Extra configuration file found and loaded\n'
        'Extra configuration path: .*testdata[/\\\\]\\.ycm_extra_conf\\.py\n'
        '[\\w\\W]*'
        'Server running at: .+\n'
        'Server process ID: \\d+\n'
        'Server logfiles:\n'
        '  .+\n'
        '  .+' )
    )
コード例 #11
0
def DebugInfo_Unity_test( app ):
  # Main TU
  app.post_json( '/load_extra_conf_file',
                 { 'filepath': PathToTestFile( '.ycm_extra_conf.py' ) } )

  for filename in [ 'unity.cc', 'unity.h', 'unitya.cc' ]:
    request_data = BuildRequest( filepath = PathToTestFile( filename ),
                                 filetype = 'cpp' )
    assert_that(
      app.post_json( '/debug_info', request_data ).json,
      has_entry( 'completer', has_entries( {
        'name': 'C-family',
        'servers': empty(),
        'items': contains(
          has_entries( {
            'key': 'compilation database path',
            'value': 'None'
          } ),
          has_entries( {
            'key': 'flags',
            'value': matches_regexp( "\\[u?'-x', u?'c\\+\\+', .*\\]" )
          } ),
          has_entries( {
            'key': 'translation unit',
            'value': PathToTestFile( 'unity.cc' )
          } )
        )
      } ) )
    )
コード例 #12
0
def DebugInfo_FlagsWhenExtraConfLoadedAndNoCompilationDatabase_test( app ):
  app.post_json( '/load_extra_conf_file',
                 { 'filepath': PathToTestFile( '.ycm_extra_conf.py' ) } )
  request_data = BuildRequest( filepath = PathToTestFile( 'basic.cpp' ),
                               filetype = 'cpp' )
  assert_that(
    app.post_json( '/debug_info', request_data ).json,
    has_entry( 'completer', has_entries( {
      'name': 'C-family',
      'servers': empty(),
      'items': contains(
        has_entries( {
          'key': 'compilation database path',
          'value': 'None'
        } ),
        has_entries( {
          'key': 'flags',
          'value': matches_regexp( "\\[u?'-x', u?'c\\+\\+', .*\\]" )
        } ),
        has_entries( {
          'key': 'translation unit',
          'value': PathToTestFile( 'basic.cpp' )
        } )
      )
    } ) )
  )
コード例 #13
0
def Subcommands_OrganizeImports_test( app ):
  filepath = PathToTestFile( 'imports.ts' )
  RunTest( app, {
    'description': 'OrganizeImports removes unused imports, '
                   'coalesces imports from the same module, and sorts them',
    'request': {
      'command': 'OrganizeImports',
      'filepath': filepath,
    },
    'expect': {
      'response': requests.codes.ok,
      'data': has_entries( {
        'fixits': contains( has_entries( {
          'chunks': contains(
            ChunkMatcher(
              matches_regexp(
                'import \\* as lib from "library";\r?\n'
                'import func, { func1, func2 } from "library";\r?\n' ),
              LocationMatcher( filepath,  1, 1 ),
              LocationMatcher( filepath,  2, 1 ) ),
            ChunkMatcher(
              '',
              LocationMatcher( filepath,  5, 1 ),
              LocationMatcher( filepath,  6, 1 ) ),
            ChunkMatcher(
              '',
              LocationMatcher( filepath,  9, 1 ),
              LocationMatcher( filepath, 10, 1 ) ),
          )
        } ) )
      } )
    }
  } )
コード例 #14
0
def verify_installed_package_matches_version_regexp(context, package, regex):
    when_i_run_command(
        context,
        "dpkg-query --showformat='${{Version}}' --show {}".format(package),
        "as non-root",
    )
    assert_that(context.process.stdout.strip(), matches_regexp(regex))
コード例 #15
0
ファイル: subcommands_test.py プロジェクト: lokesh541/ycmd
def Subcommands_Format_ExtraConf_BraceOnNewLine_test(app):
    WaitUntilCompleterServerReady(app, 'javascript')
    filepath = PathToTestFile('extra_confs', 'func.js')
    RunTest(
        app, {
            'description': 'Format with an extra conf, braces on new line',
            'request': {
                'command': 'Format',
                'filepath': filepath,
                'options': {
                    'tab_size': 4,
                    'insert_spaces': True
                }
            },
            'expect': {
                'response':
                requests.codes.ok,
                'data':
                has_entries({
                    'fixits':
                    contains_exactly(
                        has_entries({
                            'chunks':
                            contains_exactly(
                                ChunkMatcher(matches_regexp('\r?\n'),
                                             LocationMatcher(filepath, 1, 19),
                                             LocationMatcher(filepath, 1, 20)),
                                ChunkMatcher('    ',
                                             LocationMatcher(filepath, 2, 1),
                                             LocationMatcher(filepath, 2, 1)),
                            )
                        }))
                })
            }
        })
コード例 #16
0
def DebugInfo_Unity( app ):
  # Main TU
  app.post_json( '/load_extra_conf_file',
                 { 'filepath': PathToTestFile( '.ycm_extra_conf.py' ) } )

  for filename in [ 'unity.cc', 'unity.h', 'unitya.cc' ]:
    request_data = BuildRequest( filepath = PathToTestFile( filename ),
                                 filetype = 'cpp' )
    assert_that(
      app.post_json( '/debug_info', request_data ).json,
      has_entry( 'completer', has_entries( {
        'name': 'C-family',
        'servers': empty(),
        'items': contains(
          has_entries( {
            'key': 'compilation database path',
            'value': 'None'
          } ),
          has_entries( {
            'key': 'flags',
            'value': matches_regexp( "\['-x', 'c\+\+', .*\]" )
          } ),
          has_entries( {
            'key': 'translation_unit',
            'value': PathToTestFile( 'unity.cpp' )
          } )
        )
      } ) )
    )
コード例 #17
0
 def _select_comparison_method(self, left, right, comparison_type):
     if comparison_type == Types.EQUAL:
         assert_that(left, equal_to(right))
     elif comparison_type == Types.NOT_EQUAL:
         assert_that(left, is_not(equal_to(right)))
     elif comparison_type == Types.LESS_THAN:
         assert_that(left, less_than(right))
     elif comparison_type == Types.LESS_THAN_EQUAL:
         assert_that(left, less_than_or_equal_to(right))
     elif comparison_type == Types.GREATER_THAN:
         assert_that(left, greater_than(right))
     elif comparison_type == Types.GREATER_THAN_EQUAL:
         assert_that(left, greater_than_or_equal_to(right))
     elif comparison_type == Types.IS:
         assert_that(left, is_(right))
     elif comparison_type == Types.IS_NOT:
         assert_that(left, is_not(right))
     elif comparison_type == Types.IN:
         assert_that(left, is_in(right))
     elif comparison_type == Types.NOT_IN:
         assert_that(left, is_not(is_in(right)))
     elif comparison_type == Types.MATCHES_REGEXP:
         assert_that(left, matches_regexp(right))
     else:
         raise Exception()
コード例 #18
0
def DebugInfo_FlagsWhenExtraConfLoadedAndNoCompilationDatabase_test( app ):
  app.post_json( '/load_extra_conf_file',
                 { 'filepath': PathToTestFile( '.ycm_extra_conf.py' ) } )
  request_data = BuildRequest( filepath = PathToTestFile( 'basic.cpp' ),
                               filetype = 'cpp' )
  assert_that(
    app.post_json( '/debug_info', request_data ).json,
    has_entry( 'completer', has_entries( {
      'name': 'C-family',
      'servers': empty(),
      'items': contains_exactly(
        has_entries( {
          'key': 'compilation database path',
          'value': 'None'
        } ),
        has_entries( {
          'key': 'flags',
          'value': matches_regexp( "\\['-x', 'c\\+\\+', .*\\]" )
        } ),
        has_entries( {
          'key': 'translation unit',
          'value': PathToTestFile( 'basic.cpp' )
        } )
      )
    } ) )
  )
コード例 #19
0
def test_has_rows(db):
    assert_that(
        db,
        has_table_with_rows(
            "sausages",
            contains_inanyorder(
                has_properties(kind="cumberland"),
                has_properties(kind="lincolnshire"),
                has_properties(kind="vegetarian"),
            ),
        ),
    )
    assert_that(
        db,
        not_(
            has_table_with_rows("sausages",
                                has_item(has_properties(kind="vegan")))))
    assert_that(
        db,
        not_(
            has_table_with_rows(
                "bacon",
                contains_exactly(has_properties(kind="smoked"),
                                 has_properties(kind="unsmoked")),
            )),
    )
    assert_that(
        has_table_with_rows(
            "sausages",
            contains_exactly(has_properties(kind="cumberland"),
                             has_properties(kind="lincolnshire")),
        ),
        has_string(
            matches_regexp(
                r"DB connection with table 'sausages' with rows matching a sequence containing \["
                r"\(?an object with a property 'kind' matching 'cumberland'\)?, "
                r"\(?an object with a property 'kind' matching 'lincolnshire'\)?"
                r"\]")),
    )
    assert_that(
        has_table_with_rows("sausages",
                            has_item(has_properties(kind="vegan"))),
        mismatches_with(
            db,
            all_of(contains_string("was <["),
                   contains_string("RowTuple(kind='vegetarian', rating=0)")),
        ),
    )
    assert_that(
        has_table_with_rows(
            "bacon",
            contains_exactly(has_properties(kind="smoked"),
                             has_properties(kind="unsmoked")),
        ),
        mismatches_with(
            db,
            "SQL statement 'SELECT * FROM bacon;' gives 'OperationalError' <no such table: bacon>",
        ),
    )
コード例 #20
0
ファイル: debug_info_test.py プロジェクト: BielosX/ycmd
def DebugInfo_ServerIsNotRunning_NoSolution_test( app ):
  request_data = BuildRequest( filetype = 'cs' )
  assert_that(
    app.post_json( '/debug_info', request_data ).json,
    matches_regexp( 'C# completer debug information:\n'
                    '  OmniSharp not running\n'
                    '  OmniSharp executable: .+\n'
                    '  OmniSharp solution: not found' ) )
コード例 #21
0
    def test_data_uri_converted_to_image(self, base64_image):
        field = serializers.Base64ImageField()

        output = field.to_internal_value(b'data:image/png;base64,' +
                                         base64_image)  # noqa: WPS336

        assert_that(output, is_(instance_of(ContentFile)))
        assert_that(output.name, matches_regexp(r'[a-z0-9-]{36}\.png'))
コード例 #22
0
ファイル: test_phone_view.py プロジェクト: pc-m/wazo-dird
    def test_that_lookup_replace_url_by_proxy_when_paging(self):
        proxy_url = 'http://my-proxy.com/lookup'
        result = self.get_lookup_cisco(self.profile,
                                       VALID_UUID,
                                       term='user',
                                       proxy=proxy_url)

        assert_that(result, matches_regexp(URL_REGEX.format(proxy_url)))
コード例 #23
0
def YouCompleteMe_NotifyUserIfServerCrashed_UnexpectedExitCode_test():
  message = ( "The ycmd server SHUT DOWN \(restart with ':YcmRestartServer'\). "
              "Unexpected exit code 1. Type "
              "':YcmToggleLogs ycmd_\d+_stderr_.+.log' to check the logs." )
  RunNotifyUserIfServerCrashed( {
    'return_code': 1,
    'expected_message': matches_regexp( message )
  } )
コード例 #24
0
ファイル: youcompleteme_test.py プロジェクト: naryga/dotfiles
def YouCompleteMe_NotifyUserIfServerCrashed_UnexpectedExitCode_test():
  message = ( "The ycmd server SHUT DOWN \(restart with ':YcmRestartServer'\). "
              "Unexpected exit code 1. Type "
              "':YcmToggleLogs ycmd_\d+_stderr_.+.log' to check the logs." )
  RunNotifyUserIfServerCrashed( {
    'return_code': 1,
    'expected_message': matches_regexp( message )
  } )
コード例 #25
0
def then_i_see_an_ami_message_on_the_queue(step, event_name, queue):
    events = bus_helper.get_messages_from_bus(queue)

    matcher_dict = dict((event_line['header'], matches_regexp(event_line['value']))
                        for event_line in step.hashes)

    assert_that(events, has_item(all_of(has_entry('name', event_name),
                                        has_entry('data', has_entries(matcher_dict)))))
コード例 #26
0
ファイル: debug_info_test.py プロジェクト: tianser/vim
def DebugInfo_ExtraConfFoundButNotLoaded_test(app):
    request_data = BuildRequest(filepath=PathToTestFile('basic.cpp'),
                                filetype='cpp')
    assert_that(
        app.post_json('/debug_info', request_data).json,
        matches_regexp('C-family completer debug information:\n'
                       '  Configuration file found but not loaded\n'
                       '  Configuration path: .+'))
コード例 #27
0
def when_i_verify_file_is_empty_on_machine(context, file_name, instance_name):
    command = 'sh -c "cat {} | wc -l"'.format(file_name)
    when_i_run_command(context,
                       command,
                       user_spec="with sudo",
                       instance_name=instance_name)

    assert_that(context.process.stdout.strip(), matches_regexp("0"))
コード例 #28
0
ファイル: youcompleteme_test.py プロジェクト: naryga/dotfiles
def YouCompleteMe_NotifyUserIfServerCrashed_UnexpectedCore_test():
  message = ( "The ycmd server SHUT DOWN \(restart with ':YcmRestartServer'\). "
              "Unexpected error while loading the YCM core library. Type "
              "':YcmToggleLogs ycmd_\d+_stderr_.+.log' to check the logs." )
  RunNotifyUserIfServerCrashed( {
    'return_code': 3,
    'expected_message': matches_regexp( message )
  } )
コード例 #29
0
def DebugInfo_ServerIsNotRunning_NoSolution_test(app):
    request_data = BuildRequest(filetype='cs')
    assert_that(
        app.post_json('/debug_info', request_data).json,
        matches_regexp('C# completer debug information:\n'
                       '  OmniSharp not running\n'
                       '  OmniSharp executable: .+\n'
                       '  OmniSharp solution: not found'))
コード例 #30
0
def YouCompleteMe_NotifyUserIfServerCrashed_UnexpectedCore_test():
  message = ( "The ycmd server SHUT DOWN \(restart with ':YcmRestartServer'\). "
              "Unexpected error while loading the YCM core library. Type "
              "':YcmToggleLogs ycmd_\d+_stderr_.+.log' to check the logs." )
  RunNotifyUserIfServerCrashed( {
    'return_code': 3,
    'expected_message': matches_regexp( message )
  } )
コード例 #31
0
def test_decorate(mock_server):
    imposter = Imposter(Stub(responses=Response(body="The time is ${TIME}.", decorate=JS)))

    with mock_server(imposter):
        response = requests.get(imposter.url)

        assert_that(
            response, is_response().with_body(matches_regexp(r"The time is \d\d:\d\d:\d\d\."))
        )
コード例 #32
0
def DebugInfo_ServerIsNotRunning_LogfilesDoNotExist_test( app ):
  with UserOption( 'server_keep_logfiles', False ):
    StopCompleterServer( app, 'javascript' )
    request_data = BuildRequest( filetype = 'javascript' )
    assert_that(
      app.post_json( '/debug_info', request_data ).json,
      matches_regexp( 'JavaScript completer debug information:\n'
                      '  Tern is not running\n'
                      '  Tern executable: .+' ) )
コード例 #33
0
def step_impl(context):
    response_text = context.requestConfigManager.get_response_full_text()
    try:
        response = tuple(response_text.split(':'))
        session_number = response[1]
        logger.info('session number : ' + session_number)
        assert_that(session_number, matches_regexp('^[0-9]+$'))
    except:
        logger.info('User is not logged')
コード例 #34
0
ファイル: debug_info_test.py プロジェクト: BielosX/ycmd
def DebugInfo_ExtraConfFoundButNotLoaded_test( app ):
  request_data = BuildRequest( filepath = PathToTestFile( 'basic.cpp' ),
                               filetype = 'cpp' )
  assert_that(
    app.post_json( '/debug_info', request_data ).json,
    matches_regexp(
      'C-family completer debug information:\n'
      '  Configuration file found but not loaded\n'
      '  Configuration path: .+' ) )
コード例 #35
0
ファイル: debug_info_test.py プロジェクト: tianser/vim
def DebugInfo_ServerIsRunning_test(app):
    request_data = BuildRequest(filetype='typescript')
    assert_that(
        app.post_json('/debug_info', request_data).json,
        matches_regexp('TypeScript completer debug information:\n'
                       '  TSServer running\n'
                       '  TSServer process ID: \d+\n'
                       '  TSServer executable: .+\n'
                       '  TSServer logfile: .+'))
コード例 #36
0
    def test_that_export_with_empty_values_returns_empty_strings(self):
        self.post_personal({'firstname': 'Alice', 'lastname': ''})

        result = self.export_personal()

        result = result.split('\r\n')
        assert_that(result[0], equal_to('firstname,id,lastname'))
        assert_that(result[1:-1],
                    contains_inanyorder(matches_regexp('Alice,[^,]*,$')))
        assert_that(result[-1], equal_to(''))
コード例 #37
0
ファイル: debug_info_test.py プロジェクト: tianser/vim
def DebugInfo_ServerIsNotRunning_LogfilesExist_test(app):
    with UserOption('server_keep_logfiles', True):
        StopCompleterServer(app, filetype='typescript')
        request_data = BuildRequest(filetype='typescript')
        assert_that(
            app.post_json('/debug_info', request_data).json,
            matches_regexp('TypeScript completer debug information:\n'
                           '  TSServer no longer running\n'
                           '  TSServer executable: .+\n'
                           '  TSServer logfile: .+'))
コード例 #38
0
def YouCompleteMe_ToggleLogs_WithoutParameters_test(ycm, post_vim_message):
    ycm.ToggleLogs()

    assert_that(
        # Argument passed to PostVimMessage.
        post_vim_message.call_args[0][0],
        matches_regexp('Available logfiles are:\n'
                       'ycm_.+.log\n'
                       'ycmd_\d+_stderr_.+.log\n'
                       'ycmd_\d+_stdout_.+.log'))
コード例 #39
0
def Subcommands_GetType_test():
    tests = (((11, 7), 'instance int'), ((11, 20), 'def some_function()'),
             ((12, 15), 'class SomeClass(*args, **kwargs)'),
             ((13, 8), 'instance SomeClass'),
             ((13, 17), 'def SomeMethod(first_param, second_param)'),
             ((19, 4),
              matches_regexp('^(instance str, instance int|'
                             'instance int, instance str)$')))
    for test in tests:
        yield Subcommands_GetType, test[0], test[1]
コード例 #40
0
def DebugInfo_ServerIsNotRunning_LogfilesDoNotExist_test( app ):
  with UserOption( 'server_keep_logfiles', False ):
    StopGoCodeServer( app )
    subcommands_data = BuildRequest( completer_target = 'go' )
    assert_that(
      app.post_json( '/debug_info', subcommands_data ).json,
      matches_regexp( 'Go completer debug information:\n'
                      '  Gocode is not running\n'
                      '  Gocode binary: .+\n'
                      '  Godef binary: .+' ) )
コード例 #41
0
ファイル: debug_info_test.py プロジェクト: bshimanuki/ycmd
def DebugInfo_ServerIsNotRunning_LogfilesDoNotExist_test(app):
    with UserOption("server_keep_logfiles", False):
        StopCompleterServer(app, filetype="typescript")
        request_data = BuildRequest(filetype="typescript")
        assert_that(
            app.post_json("/debug_info", request_data).json,
            matches_regexp(
                "TypeScript completer debug information:\n" "  TSServer is not running\n" "  TSServer executable: .+"
            ),
        )
コード例 #42
0
ファイル: debug_info_test.py プロジェクト: iamshf/ycmd
def DebugInfo_ServerIsNotRunning_LogfilesDoNotExist_test(app):
    with UserOption('server_keep_logfiles', False):
        StopGoCodeServer(app)
        subcommands_data = BuildRequest(completer_target='go')
        assert_that(
            app.post_json('/debug_info', subcommands_data).json,
            matches_regexp('Go completer debug information:\n'
                           '  Gocode is not running\n'
                           '  Gocode binary: .+\n'
                           '  Godef binary: .+'))
コード例 #43
0
    def test_that_export_with_non_ascii_is_ok(self):
        self.post_personal({'firstname': 'Éloïse'})

        result = self.export_personal()

        result = result.split('\r\n')
        assert_that(result[0], equal_to('firstname,id'))
        assert_that(result[1:-1],
                    contains_inanyorder(matches_regexp('Éloïse,[^,]*')))
        assert_that(result[-1], equal_to(''))
コード例 #44
0
ファイル: debug_info_test.py プロジェクト: tianser/vim
def DebugInfo_ServerIsNotRunning_LogfilesDoNotExist_test(app):
    with UserOption('server_keep_logfiles', False):
        StopCompleterServer(app, 'python')
        request_data = BuildRequest(filetype='python')
        assert_that(
            app.post_json('/debug_info', request_data).json,
            matches_regexp('Python completer debug information:\n'
                           '  JediHTTP is not running\n'
                           '  JediHTTP executable: .+\n'
                           '  Python interpreter: .+'))
コード例 #45
0
ファイル: debug_info_test.py プロジェクト: BielosX/ycmd
def DebugInfo_ServerIsNotRunning_LogfilesDoNotExist_test( app ):
  with UserOption( 'server_keep_logfiles', False ):
    StopCompleterServer( app, 'python' )
    request_data = BuildRequest( filetype = 'python' )
    assert_that(
      app.post_json( '/debug_info', request_data ).json,
      matches_regexp( 'Python completer debug information:\n'
                      '  JediHTTP is not running\n'
                      '  JediHTTP executable: .+\n'
                      '  Python interpreter: .+' ) )
コード例 #46
0
def DebugInfo_ServerIsRunning_test( app ):
  request_data = BuildRequest( filetype = 'javascript' )
  assert_that(
    app.post_json( '/debug_info', request_data ).json,
    matches_regexp( 'JavaScript completer debug information:\n'
                    '  Tern running at: http://127.0.0.1:\d+\n'
                    '  Tern process ID: \d+\n'
                    '  Tern executable: .+\n'
                    '  Tern logfiles:\n'
                    '    .+\n'
                    '    .+' ) )
コード例 #47
0
ファイル: debug_info_test.py プロジェクト: BielosX/ycmd
def DebugInfo_ExtraConfLoaded_test( app ):
  app.post_json( '/load_extra_conf_file',
                 { 'filepath': PathToTestFile( '.ycm_extra_conf.py' ) } )
  request_data = BuildRequest( filepath = PathToTestFile( 'basic.cpp' ),
                               filetype = 'cpp' )
  assert_that(
    app.post_json( '/debug_info', request_data ).json,
    matches_regexp( 'C-family completer debug information:\n'
                    '  Configuration file found and loaded\n'
                    '  Configuration path: .+\n'
                    '  Flags: .+' ) )
コード例 #48
0
ファイル: debug_info_test.py プロジェクト: BielosX/ycmd
def DebugInfo_ServerIsRunning_test( app ):
  request_data = BuildRequest( filetype = 'go' )
  assert_that(
    app.post_json( '/debug_info', request_data ).json,
    matches_regexp( 'Go completer debug information:\n'
                    '  Gocode running at: http://127.0.0.1:\d+\n'
                    '  Gocode process ID: \d+\n'
                    '  Gocode executable: .+\n'
                    '  Gocode logfiles:\n'
                    '    .+\n'
                    '    .+\n'
                    '  Godef executable: .+' ) )
コード例 #49
0
ファイル: debug_info_test.py プロジェクト: bshimanuki/ycmd
def DebugInfo_ServerIsRunning_test(app):
    request_data = BuildRequest(filetype="typescript")
    assert_that(
        app.post_json("/debug_info", request_data).json,
        matches_regexp(
            "TypeScript completer debug information:\n"
            "  TSServer running\n"
            "  TSServer process ID: \d+\n"
            "  TSServer executable: .+\n"
            "  TSServer logfile: .+"
        ),
    )
コード例 #50
0
def YouCompleteMe_ToggleLogs_WithoutParameters_test( ycm, post_vim_message ):
  ycm.ToggleLogs()

  assert_that(
    # Argument passed to PostVimMessage.
    post_vim_message.call_args[ 0 ][ 0 ],
    matches_regexp(
      'Available logfiles are:\n'
      'ycm_.+.log\n'
      'ycmd_\d+_stderr_.+.log\n'
      'ycmd_\d+_stdout_.+.log' )
  )
コード例 #51
0
ファイル: debug_info_test.py プロジェクト: BielosX/ycmd
def DebugInfo_ServerIsRunning_test( app ):
  request_data = BuildRequest( filetype = 'python' )
  assert_that(
    app.post_json( '/debug_info', request_data ).json,
    matches_regexp( 'Python completer debug information:\n'
                    '  JediHTTP running at: http://127.0.0.1:\d+\n'
                    '  JediHTTP process ID: \d+\n'
                    '  JediHTTP executable: .+\n'
                    '  JediHTTP logfiles:\n'
                    '    .+\n'
                    '    .+\n'
                    '  Python interpreter: .+' ) )
コード例 #52
0
def DebugInfo_ServerIsRunning_test( app ):
  subcommands_data = BuildRequest( completer_target = 'go' )
  assert_that(
    app.post_json( '/debug_info', subcommands_data ).json,
    matches_regexp( 'Go completer debug information:\n'
                    '  Gocode running at: http://127.0.0.1:\d+\n'
                    '  Gocode process ID: \d+\n'
                    '  Gocode binary: .+\n'
                    '  Gocode logfiles:\n'
                    '    .+\n'
                    '    .+\n'
                    '  Godef binary: .+' ) )
コード例 #53
0
ファイル: subcommands_test.py プロジェクト: Valloric/ycmd
def Subcommands_GetType_test():
  tests = (
    ( ( 11,  7 ), 'instance int' ),
    ( ( 11, 20 ), 'def some_function()' ),
    ( ( 12, 15 ), 'class SomeClass(*args, **kwargs)' ),
    ( ( 13,  8 ), 'instance SomeClass' ),
    ( ( 13, 17 ), 'def SomeMethod(first_param, second_param)' ),
    ( ( 19,  4 ), matches_regexp( '^(instance str, instance int|'
                                  'instance int, instance str)$' ) )
  )
  for test in tests:
    yield Subcommands_GetType, test[ 0 ], test[ 1 ]
コード例 #54
0
ファイル: debug_info_test.py プロジェクト: BielosX/ycmd
def DebugInfo_ServerIsNotRunning_LogfilesExist_test( app ):
  with UserOption( 'server_keep_logfiles', True ):
    StopCompleterServer( app, 'go' )
    request_data = BuildRequest( filetype = 'go' )
    assert_that(
      app.post_json( '/debug_info', request_data ).json,
      matches_regexp( 'Go completer debug information:\n'
                      '  Gocode no longer running\n'
                      '  Gocode executable: .+\n'
                      '  Gocode logfiles:\n'
                      '    .+\n'
                      '    .+\n'
                      '  Godef executable: .+' ) )
コード例 #55
0
ファイル: debug_info_test.py プロジェクト: bshimanuki/ycmd
def DebugInfo_ServerIsRunning_test(app):
    request_data = BuildRequest(filetype="rust")
    assert_that(
        app.post_json("/debug_info", request_data).json,
        matches_regexp(
            "Rust completer debug information:\n"
            "  Racerd running at: http://127.0.0.1:\d+\n"
            "  Racerd process ID: \d+\n"
            "  Racerd executable: .+\n"
            "  Racerd logfiles:\n"
            "    .+\n"
            "    .+\n"
            "  Rust sources: .+"
        ),
    )
コード例 #56
0
def YouCompleteMe_DebugInfo_ServerRunning_test( ycm ):
  current_buffer = VimBuffer( 'current_buffer' )
  with MockVimBuffers( [ current_buffer ], current_buffer ):
    assert_that(
      ycm.DebugInfo(),
      matches_regexp(
        'Client logfile: .+\n'
        'Server has Clang support compiled in: (True|False)\n'
        '(Clang version: .+\n)?'
        'Server running at: .+\n'
        'Server process ID: \d+\n'
        'Server logfiles:\n'
        '  .+\n'
        '  .+' )
    )
コード例 #57
0
ファイル: debug_info_test.py プロジェクト: bshimanuki/ycmd
def DebugInfo_ServerIsNotRunning_LogfilesExist_test(app):
    with UserOption("server_keep_logfiles", True):
        StopCompleterServer(app, "rust")
        request_data = BuildRequest(filetype="rust")
        assert_that(
            app.post_json("/debug_info", request_data).json,
            matches_regexp(
                "Rust completer debug information:\n"
                "  Racerd no longer running\n"
                "  Racerd executable: .+\n"
                "  Racerd logfiles:\n"
                "    .+\n"
                "    .+\n"
                "  Rust sources: .+"
            ),
        )
コード例 #58
0
def YouCompleteMe_DebugInfo_ServerNotRunning_test( ycm ):
  StopServer( ycm )

  current_buffer = VimBuffer( 'current_buffer' )
  with MockVimBuffers( [ current_buffer ], current_buffer ):
    assert_that(
      ycm.DebugInfo(),
      matches_regexp(
        'Client logfile: .+\n'
        'Server crashed, no debug info from server\n'
        'Server running at: .+\n'
        'Server process ID: \d+\n'
        'Server logfiles:\n'
        '  .+\n'
        '  .+' )
    )