Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
devel:languages:python
python-cpplint
deprecated-unittest-aliases.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File deprecated-unittest-aliases.patch of Package python-cpplint
From ea0004c2ae98c4e275f58d20bf42095160171f87 Mon Sep 17 00:00:00 2001 From: Karthikeyan Singaravelan <tir.karthi@gmail.com> Date: Sun, 17 Oct 2021 11:29:03 +0530 Subject: [PATCH] Refactor deprecated unittest aliases for Python 3.11 compatibility. --- cpplint_unittest.py | 177 +++++++++++++++++++++++--------------------- 1 file changed, 93 insertions(+), 84 deletions(-) Index: cpplint-1.6.1/cpplint_unittest.py =================================================================== --- cpplint-1.6.1.orig/cpplint_unittest.py +++ cpplint-1.6.1/cpplint_unittest.py @@ -152,13 +152,15 @@ class CpplintTestBase(unittest.TestCase) def setUp(self): # Allow subclasses to cheat os.path.abspath called in FileInfo class. self.os_path_abspath_orig = os.path.abspath + self.assertEquals = self.assertEqual + self.assertTrue = self.assertTrue def tearDown(self): os.path.abspath = self.os_path_abspath_orig # Perform lint on single line of input and return the error message. def PerformSingleLineLint(self, code): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) lines = code.split('\n') cpplint.RemoveMultiLineComments('foo.h', lines, error_collector) clean_lines = cpplint.CleansedLines(lines) @@ -176,7 +178,7 @@ class CpplintTestBase(unittest.TestCase) # Perform lint over multiple lines and return the error message. def PerformMultiLineLint(self, code): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) lines = code.split('\n') cpplint.RemoveMultiLineComments('foo.h', lines, error_collector) lines = cpplint.CleansedLines(lines) @@ -193,7 +195,7 @@ class CpplintTestBase(unittest.TestCase) # Similar to PerformMultiLineLint, but calls CheckLanguage instead of # CheckForNonStandardConstructs def PerformLanguageRulesCheck(self, file_name, code): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) include_state = cpplint._IncludeState() nesting_state = cpplint.NestingState() lines = code.split('\n') @@ -221,7 +223,7 @@ class CpplintTestBase(unittest.TestCase) The accumulated errors. """ file_name = 'foo.cc' - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) function_state = cpplint._FunctionState() lines = code.split('\n') cpplint.RemoveMultiLineComments(file_name, lines, error_collector) @@ -233,7 +235,7 @@ class CpplintTestBase(unittest.TestCase) def PerformIncludeWhatYouUse(self, code, filename='foo.h', io=codecs): # First, build up the include state. - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) include_state = cpplint._IncludeState() nesting_state = cpplint.NestingState() lines = code.split('\n') @@ -277,7 +279,7 @@ class CpplintTestBase(unittest.TestCase) self.doTestBlankLinesCheck(lines, start_errors, end_errors, extension) def doTestBlankLinesCheck(self, lines, start_errors, end_errors, extension): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.' + extension, extension, lines, error_collector) self.assertEqual( start_errors, @@ -294,7 +296,7 @@ class CpplintTestBase(unittest.TestCase) class CpplintTest(CpplintTestBase): def GetNamespaceResults(self, lines): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.RemoveMultiLineComments('foo.h', lines, error_collector) lines = cpplint.CleansedLines(lines) nesting_state = cpplint.NestingState() @@ -509,7 +511,7 @@ class CpplintTest(CpplintTestBase): 'Use int16/int64/etc, rather than the C type long' ' [runtime/int] [4]') # NOLINTNEXTLINE silences warning for the next line instead of current line - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('test.cc', 'cc', ['// Copyright 2014 Your Company.', '// NOLINTNEXTLINE(whitespace/line_length)', @@ -518,7 +520,7 @@ class CpplintTest(CpplintTestBase): error_collector) self.assertEqual('', error_collector.Results()) # LINT_C_FILE silences cast warnings for entire file. - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('test.h', 'h', ['// Copyright 2014 Your Company.', '// NOLINT(build/header_guard)', @@ -552,7 +554,7 @@ class CpplintTest(CpplintTestBase): 'vim: se filetype=c :', 'vim: se sw=8 filetype=c :', 'vim: se sw=8 filetype=c ts=8 :']: - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('test.h', 'h', ['// Copyright 2014 Your Company.', '// NOLINT(build/header_guard)', @@ -564,7 +566,7 @@ class CpplintTest(CpplintTestBase): error_collector) self.assertEqual('', error_collector.Results()) # LINT_KERNEL_FILE silences whitespace/tab warnings for entire file. - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('test.h', 'h', ['// Copyright 2014 Your Company.', '// NOLINT(build/header_guard)', @@ -576,7 +578,7 @@ class CpplintTest(CpplintTestBase): error_collector) self.assertEqual('', error_collector.Results()) # NOLINT, NOLINTNEXTLINE silences the readability/braces warning for "};". - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('test.cc', 'cc', ['// Copyright 2014 Your Company.', 'for (int i = 0; i != 100; ++i) {', @@ -837,7 +839,7 @@ class CpplintTest(CpplintTestBase): self.TestLint('std::function< int(bool) >', '') self.TestLint('mfunction<int(bool)>', '') - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData( 'test.cc', 'cc', ['// Copyright 2014 Your Company. All Rights Reserved.', @@ -876,7 +878,7 @@ class CpplintTest(CpplintTestBase): 'MOCK_CONST_METHOD1(method, SomeType(int));', '') - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('mock.cc', 'cc', ['MOCK_METHOD1(method1,', ' bool(int));', @@ -1373,7 +1375,7 @@ class CpplintTest(CpplintTestBase): for extension in ['c', 'cc', 'cpp', 'cxx', 'c++', 'cu']: file_path = 'mydir/foo.' + extension - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, extension, ['const char* str = "This is a\\', ' multiline string.";'], @@ -1724,7 +1726,7 @@ class CpplintTest(CpplintTestBase): };""", '') # Special case for variadic arguments - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['class Foo {', ' template<typename... Args>', @@ -1734,7 +1736,7 @@ class CpplintTest(CpplintTestBase): self.assertEqual(0, error_collector.ResultList().count( 'Constructors that require multiple arguments should not be marked ' 'explicit. [runtime/explicit] [0]')) - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['class Foo {', ' template<typename... Args>', @@ -1744,7 +1746,7 @@ class CpplintTest(CpplintTestBase): self.assertEqual(0, error_collector.ResultList().count( 'Constructors that require multiple arguments should not be marked ' 'explicit. [runtime/explicit] [0]')) - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['class Foo {', ' template<typename... Args>', @@ -1754,7 +1756,7 @@ class CpplintTest(CpplintTestBase): self.assertEqual(1, error_collector.ResultList().count( 'Constructors callable with one argument should be marked explicit.' ' [runtime/explicit] [5]')) - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['class Foo {', ' template<typename... Args>', @@ -1765,7 +1767,7 @@ class CpplintTest(CpplintTestBase): 'Constructors callable with one argument should be marked explicit.' ' [runtime/explicit] [5]')) # Anything goes inside an assembly block - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['void Func() {', ' __asm__ (', @@ -1875,7 +1877,7 @@ class CpplintTest(CpplintTestBase): self.TestLint('virtual int F() %s;' % virt_specifier, error_message) self.TestLint('virtual int F() %s {' % virt_specifier, error_message) - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData( 'foo.cc', 'cc', ['// Copyright 2014 Your Company.', @@ -1900,7 +1902,7 @@ class CpplintTest(CpplintTestBase): self.TestLint('int F() final override;', error_message) self.TestLint('int F() final override {}', error_message) - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData( 'foo.cc', 'cc', ['// Copyright 2014 Your Company.', @@ -2074,7 +2076,7 @@ class CpplintTest(CpplintTestBase): for macro_name in ( 'DISALLOW_COPY_AND_ASSIGN', 'DISALLOW_IMPLICIT_CONSTRUCTORS'): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData( 'foo.cc', 'cc', ['// Copyright 2014 Your Company.', @@ -2090,7 +2092,7 @@ class CpplintTest(CpplintTestBase): ' [readability/constructors] [3]', error_collector.Results()) - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData( 'foo.cc', 'cc', ['// Copyright 2014 Your Company.', @@ -2109,7 +2111,7 @@ class CpplintTest(CpplintTestBase): ' [readability/constructors] [3]', error_collector.Results()) - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData( 'foo.cc', 'cc', ['// Copyright 2014 Your Company.', @@ -2442,7 +2444,7 @@ class CpplintTest(CpplintTestBase): # Don't warn on out-of-line method definitions. self.TestLint('void NS::Func(X& x) {', '') - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData( 'foo.cc', 'cc', ['// Copyright 2014 Your Company. All Rights Reserved.', @@ -2456,7 +2458,7 @@ class CpplintTest(CpplintTestBase): # Other potential false positives. These need full parser # state to reproduce as opposed to just TestLint. - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData( 'foo.cc', 'cc', ['// Copyright 2014 Your Company. All Rights Reserved.', @@ -2499,7 +2501,7 @@ class CpplintTest(CpplintTestBase): self.assertEqual('', error_collector.Results()) # Multi-line references - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData( 'foo.cc', 'cc', ['// Copyright 2014 Your Company. All Rights Reserved.', @@ -2525,7 +2527,7 @@ class CpplintTest(CpplintTestBase): error_collector.Results()) # A peculiar false positive due to bad template argument parsing - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData( 'foo.cc', 'cc', ['// Copyright 2014 Your Company. All Rights Reserved.', @@ -2545,7 +2547,7 @@ class CpplintTest(CpplintTestBase): '{ should almost always be at the end of the previous line' ' [whitespace/braces] [4]') - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['int function()', '{', # warning here @@ -3056,7 +3058,7 @@ class CpplintTest(CpplintTestBase): '}\n', '') # Check multiline cases. - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['// Copyright 2014 Your Company.', 'string Class', @@ -3207,7 +3209,7 @@ class CpplintTest(CpplintTestBase): # 1' line was also causing the issue. def testLinePrecededByEmptyOrCommentLines(self): def DoTest(self, lines): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', lines, error_collector) # The warning appears only once. self.assertEqual( @@ -3230,7 +3232,7 @@ class CpplintTest(CpplintTestBase): def testNewlineAtEOF(self): def DoTest(self, data, is_missing_eof): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', data.split('\n'), error_collector) # The warning appears only once. @@ -3245,7 +3247,7 @@ class CpplintTest(CpplintTestBase): def testInvalidUtf8(self): def DoTest(self, raw_bytes, has_invalid_utf8): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) if sys.version_info < (3,): unidata = unicode(raw_bytes, 'utf8', 'replace').split('\n') else: @@ -3271,7 +3273,7 @@ class CpplintTest(CpplintTestBase): def testBadCharacters(self): # Test for NUL bytes only - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('nul.cc', 'cc', ['// Copyright 2014 Your Company.', '\0', ''], error_collector) @@ -3281,7 +3283,7 @@ class CpplintTest(CpplintTestBase): # Make sure both NUL bytes and UTF-8 are caught if they appear on # the same line. - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) raw_bytes = codecs_latin_encode('\xe9x\0') if sys.version_info < (3,): unidata = unicode(raw_bytes, 'utf8', 'replace') @@ -3300,11 +3302,11 @@ class CpplintTest(CpplintTestBase): 'Line contains NUL byte. [readability/nul] [5]']) def testIsBlankLine(self): - self.assert_(cpplint.IsBlankLine('')) - self.assert_(cpplint.IsBlankLine(' ')) - self.assert_(cpplint.IsBlankLine(' \t\r\n')) - self.assert_(not cpplint.IsBlankLine('int a;')) - self.assert_(not cpplint.IsBlankLine('{')) + self.assertTrue(cpplint.IsBlankLine('')) + self.assertTrue(cpplint.IsBlankLine(' ')) + self.assertTrue(cpplint.IsBlankLine(' \t\r\n')) + self.assertTrue(not cpplint.IsBlankLine('int a;')) + self.assertTrue(not cpplint.IsBlankLine('{')) def testBlankLinesCheck(self): self.TestBlankLinesCheck(['{\n', '\n', '\n', '}\n'], 1, 1) @@ -3323,7 +3325,7 @@ class CpplintTest(CpplintTestBase): ['int x(\n', ' int a) {\n', '\n', 'return 0;\n', '}'], 1, 0) def testAllowBlankLineBeforeClosingNamespace(self): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['namespace {', '', @@ -3348,7 +3350,7 @@ class CpplintTest(CpplintTestBase): ' [whitespace/blank_line] [3]')) def testAllowBlankLineBeforeIfElseChain(self): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['if (hoge) {', '', # No warning @@ -3365,7 +3367,7 @@ class CpplintTest(CpplintTestBase): ' [whitespace/blank_line] [3]')) def testAllowBlankLineAfterExtern(self): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['extern "C" {', '', @@ -3381,7 +3383,7 @@ class CpplintTest(CpplintTestBase): ' [whitespace/blank_line] [3]')) def testBlankLineBeforeSectionKeyword(self): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['class A {', ' public:', @@ -3417,7 +3419,7 @@ class CpplintTest(CpplintTestBase): ' [whitespace/blank_line] [3]')) def testNoBlankLineAfterSectionKeyword(self): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['class A {', ' public:', @@ -3441,7 +3443,7 @@ class CpplintTest(CpplintTestBase): ' [whitespace/blank_line] [3]')) def testAllowBlankLinesInRawStrings(self): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['// Copyright 2014 Your Company.', 'static const char *kData[] = {R"(', @@ -3454,7 +3456,7 @@ class CpplintTest(CpplintTestBase): self.assertEqual('', error_collector.Results()) def testElseOnSameLineAsClosingBraces(self): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['if (hoge) {', '}', @@ -3468,7 +3470,7 @@ class CpplintTest(CpplintTestBase): 'An else should appear on the same line as the preceding }' ' [whitespace/newline] [4]')) - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['if (hoge) {', '', @@ -3482,7 +3484,7 @@ class CpplintTest(CpplintTestBase): 'An else should appear on the same line as the preceding }' ' [whitespace/newline] [4]')) - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['if (hoge) {', '', @@ -3494,7 +3496,7 @@ class CpplintTest(CpplintTestBase): ' [whitespace/newline] [4]')) def testMultipleStatementsOnSameLine(self): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['for (int i = 0; i < 1; i++) {}', 'switch (x) {', @@ -3513,7 +3515,7 @@ class CpplintTest(CpplintTestBase): cpplint._cpplint_state.verbose_level = old_verbose_level def testLambdasOnSameLine(self): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) old_verbose_level = cpplint._cpplint_state.verbose_level cpplint._cpplint_state.verbose_level = 0 cpplint.ProcessFileData('foo.cc', 'cc', @@ -3524,7 +3526,7 @@ class CpplintTest(CpplintTestBase): self.assertEqual(0, error_collector.Results().count( 'More than one command on the same line [whitespace/newline] [0]')) - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) old_verbose_level = cpplint._cpplint_state.verbose_level cpplint._cpplint_state.verbose_level = 0 cpplint.ProcessFileData('foo.cc', 'cc', @@ -3536,7 +3538,7 @@ class CpplintTest(CpplintTestBase): self.assertEqual(0, error_collector.Results().count( 'More than one command on the same line [whitespace/newline] [0]')) - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) old_verbose_level = cpplint._cpplint_state.verbose_level cpplint._cpplint_state.verbose_level = 0 cpplint.ProcessFileData('foo.cc', 'cc', @@ -3548,7 +3550,7 @@ class CpplintTest(CpplintTestBase): self.assertEqual(0, error_collector.Results().count( 'More than one command on the same line [whitespace/newline] [0]')) - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) old_verbose_level = cpplint._cpplint_state.verbose_level cpplint._cpplint_state.verbose_level = 0 cpplint.ProcessFileData('foo.cc', 'cc', @@ -3561,7 +3563,7 @@ class CpplintTest(CpplintTestBase): 'More than one command on the same line [whitespace/newline] [0]')) def testEndOfNamespaceComments(self): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('foo.cc', 'cc', ['namespace {', '', @@ -4377,7 +4379,7 @@ class CpplintTest(CpplintTestBase): cpplint._DEFAULT_FILTERS = default_filters def testDuplicateHeader(self): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('path/self.cc', 'cc', ['// Copyright 2014 Your Company. All Rights Reserved.', '#include "path/self.h"', @@ -4481,7 +4483,7 @@ class CpplintTest(CpplintTestBase): def GetBuildHeaderGuardPreprocessorSymbol(self, file_path): # Figure out the expected header guard by processing an empty file. - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, 'h', [], error_collector) for error in error_collector.ResultList(): matched = re.search( @@ -4497,7 +4499,7 @@ class CpplintTest(CpplintTestBase): self.assertTrue(re.search('MYDIR_FOO_H_$', expected_guard)) # No guard at all: expect one error. - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, 'h', [], error_collector) self.assertEqual( 1, @@ -4507,7 +4509,7 @@ class CpplintTest(CpplintTestBase): error_collector.ResultList()) # No header guard, but the error is suppressed. - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, 'h', ['// Copyright 2014 Your Company.', '// NOLINT(build/header_guard)', ''], @@ -4515,7 +4517,7 @@ class CpplintTest(CpplintTestBase): self.assertEqual([], error_collector.ResultList()) # Wrong guard - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, 'h', ['#ifndef FOO_H', '#define FOO_H'], error_collector) self.assertEqual( @@ -4526,7 +4528,7 @@ class CpplintTest(CpplintTestBase): error_collector.ResultList()) # No define - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, 'h', ['#ifndef %s' % expected_guard], error_collector) self.assertEqual( @@ -4537,7 +4539,7 @@ class CpplintTest(CpplintTestBase): error_collector.ResultList()) # Mismatched define - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, 'h', ['#ifndef %s' % expected_guard, '#define FOO_H'], @@ -4550,7 +4552,7 @@ class CpplintTest(CpplintTestBase): error_collector.ResultList()) # No endif - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, 'h', ['#ifndef %s' % expected_guard, '#define %s' % expected_guard, @@ -4564,7 +4566,7 @@ class CpplintTest(CpplintTestBase): error_collector.ResultList()) # Commentless endif - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, 'h', ['#ifndef %s' % expected_guard, '#define %s' % expected_guard, @@ -4578,7 +4580,7 @@ class CpplintTest(CpplintTestBase): error_collector.ResultList()) # Commentless endif for old-style guard - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, 'h', ['#ifndef %s_' % expected_guard, '#define %s_' % expected_guard, @@ -4592,7 +4594,7 @@ class CpplintTest(CpplintTestBase): error_collector.ResultList()) # No header guard errors - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, 'h', ['#ifndef %s' % expected_guard, '#define %s' % expected_guard, @@ -4603,7 +4605,7 @@ class CpplintTest(CpplintTestBase): self.fail('Unexpected error: %s' % line) # No header guard errors for old-style guard - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, 'h', ['#ifndef %s_' % expected_guard, '#define %s_' % expected_guard, @@ -4617,7 +4619,7 @@ class CpplintTest(CpplintTestBase): try: cpplint._cpplint_state.verbose_level = 0 # Warn on old-style guard if verbosity is 0. - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, 'h', ['#ifndef %s_' % expected_guard, '#define %s_' % expected_guard, @@ -4633,7 +4635,7 @@ class CpplintTest(CpplintTestBase): cpplint._cpplint_state.verbose_level = old_verbose_level # Completely incorrect header guard - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, 'h', ['#ifndef FOO', '#define FOO', @@ -4653,7 +4655,7 @@ class CpplintTest(CpplintTestBase): error_collector.ResultList()) # incorrect header guard with nolint - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, 'h', ['#ifndef FOO // NOLINT', '#define FOO', @@ -4674,7 +4676,7 @@ class CpplintTest(CpplintTestBase): # Special case for flymake for test_file in ['mydir/foo_flymake.h', 'mydir/.flymake/foo.h']: - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(test_file, 'h', ['// Copyright 2014 Your Company.', ''], error_collector) @@ -4688,7 +4690,7 @@ class CpplintTest(CpplintTestBase): # Cuda guard file_path = 'mydir/foo.cuh' expected_guard = self.GetBuildHeaderGuardPreprocessorSymbol(file_path) - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, 'cuh', ['#ifndef FOO', '#define FOO', @@ -4708,7 +4710,7 @@ class CpplintTest(CpplintTestBase): error_collector.ResultList()) def testPragmaOnce(self): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData('mydir/foo.h', 'h', ['// Copyright 2014 Your Company.', '#pragma once', ''], error_collector) @@ -4988,7 +4990,7 @@ class CpplintTest(CpplintTestBase): self.TestLanguageRulesCheck('foo.h', code, '') def testBuildPrintfFormat(self): - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData( 'foo.cc', 'cc', [r'printf("\%%d", value);', @@ -5002,7 +5004,7 @@ class CpplintTest(CpplintTestBase): '%, [, (, and { are undefined character escapes. Unescape them.' ' [build/printf_format] [3]')) - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData( 'foo.cc', 'cc', ['// Copyright 2014 Your Company.', @@ -5121,13 +5123,13 @@ class CpplintTest(CpplintTestBase): file_path = 'mydir/googleclient/foo.cc' # There should be a copyright message in the first 10 lines - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, 'cc', [], error_collector) self.assertEqual( 1, error_collector.ResultList().count(legal_copyright_message)) - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData( file_path, 'cc', ['' for unused_i in range(10)] + [copyright_line], @@ -5137,13 +5139,13 @@ class CpplintTest(CpplintTestBase): error_collector.ResultList().count(legal_copyright_message)) # Test that warning isn't issued if Copyright line appears early enough. - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(file_path, 'cc', [copyright_line], error_collector) for message in error_collector.ResultList(): if message.find('legal/copyright') != -1: self.fail('Unexpected error: %s' % message) - error_collector = ErrorCollector(self.assert_) + error_collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData( file_path, 'cc', ['' for unused_i in range(9)] + [copyright_line], @@ -5179,14 +5181,14 @@ class Cxx11Test(CpplintTestBase): lines.append('') # Process the file and check resulting error count. - collector = ErrorCollector(self.assert_) + collector = ErrorCollector(self.assertTrue) cpplint.ProcessFileData(filename, extension, lines, collector) error_list = collector.ResultList() self.assertEqual(count, len(error_list), error_list) def TestCxx11Feature(self, code, expected_error): lines = code.split('\n') - collector = ErrorCollector(self.assert_) + collector = ErrorCollector(self.assertTrue) cpplint.RemoveMultiLineComments('foo.h', lines, collector) clean_lines = cpplint.CleansedLines(lines) cpplint.FlagCxx11Features('foo.cc', clean_lines, 0, collector) @@ -5244,7 +5246,7 @@ class Cxx14Test(CpplintTestBase): def TestCxx14Feature(self, code, expected_error): lines = code.split('\n') - collector = ErrorCollector(self.assert_) + collector = ErrorCollector(self.assertTrue) cpplint.RemoveMultiLineComments('foo.h', lines, collector) clean_lines = cpplint.CleansedLines(lines) cpplint.FlagCxx14Features('foo.cc', clean_lines, 0, collector) @@ -5261,6 +5263,9 @@ class Cxx14Test(CpplintTestBase): class CleansedLinesTest(unittest.TestCase): + def setUp(self): + self.assertEquals = self.assertEqual + def testInit(self): lines = ['Line 1', 'Line 2', @@ -5645,6 +5650,7 @@ class CheckForFunctionLengthsTest(Cpplin def setUp(self): # Reducing these thresholds for the tests speeds up tests significantly. + CpplintTestBase.setUp(self) self.old_normal_trigger = cpplint._FunctionState._NORMAL_TRIGGER self.old_test_trigger = cpplint._FunctionState._TEST_TRIGGER @@ -5996,6 +6002,7 @@ def TrimExtraIndent(text_block): class CloseExpressionTest(unittest.TestCase): def setUp(self): + self.assertEquals = self.assertEqual self.lines = cpplint.CleansedLines( # 1 2 3 4 5 # 0123456789012345678901234567890123456789012345678901234567890 @@ -6067,7 +6074,8 @@ class NestingStateTest(unittest.TestCase def setUp(self): self.nesting_state = cpplint.NestingState() - self.error_collector = ErrorCollector(self.assert_) + self.error_collector = ErrorCollector(self.assertTrue) + self.assertEquals = self.assertEqual def UpdateWithLines(self, lines): clean_lines = cpplint.CleansedLines(lines) @@ -6450,6 +6458,7 @@ class QuietTest(unittest.TestCase): self.python_executable = sys.executable or 'python' self.cpplint_test_h = os.path.join(self.this_dir_path, 'cpplint_test_header.h') + self.assertEquals = self.assertEqual open(self.cpplint_test_h, 'w').close() def tearDown(self):
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor