Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
devel:languages:python
python-cpplint
python312.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File python312.patch of Package python-cpplint
From 0e855087765db4cbe8283f614238aaa0dba74ff6 Mon Sep 17 00:00:00 2001 From: John Vandenberg <jayvdb@gmail.com> Date: Sun, 4 Feb 2024 06:33:12 +0800 Subject: [PATCH] Fix support for Python 3.12 Removes 'lint' subcommand support from setup.py --- From 0e855087765db4cbe8283f614238aaa0dba74ff6 Mon Sep 17 00:00:00 2001 From: John Vandenberg <jayvdb@gmail.com> Date: Sun, 4 Feb 2024 06:33:12 +0800 Subject: [PATCH] Fix support for Python 3.12 Removes 'lint' subcommand support from setup.py --- cpplint_unittest.py | 2 +- setup.py | 38 +------------------------------------- test-requirements | 1 - 6 files changed, 13 insertions(+), 49 deletions(-) Index: cpplint-1.6.1/cpplint_unittest.py =================================================================== --- cpplint-1.6.1.orig/cpplint_unittest.py +++ cpplint-1.6.1/cpplint_unittest.py @@ -253,10 +253,10 @@ class CpplintTestBase(unittest.TestCase) # Perform lint and compare the error message with "expected_message". def TestLint(self, code, expected_message): - self.assertEquals(expected_message, self.PerformSingleLineLint(code)) + self.assertEqual(expected_message, self.PerformSingleLineLint(code)) def TestMultiLineLint(self, code, expected_message): - self.assertEquals(expected_message, self.PerformMultiLineLint(code)) + self.assertEqual(expected_message, self.PerformMultiLineLint(code)) def TestMultiLineLintRE(self, code, expected_message_re): message = self.PerformMultiLineLint(code) @@ -265,11 +265,11 @@ class CpplintTestBase(unittest.TestCase) expected_message_re + '"') def TestLanguageRulesCheck(self, file_name, code, expected_message): - self.assertEquals(expected_message, + self.assertEqual(expected_message, self.PerformLanguageRulesCheck(file_name, code)) def TestIncludeWhatYouUse(self, code, expected_message): - self.assertEquals(expected_message, + self.assertEqual(expected_message, self.PerformIncludeWhatYouUse(code)) def TestBlankLinesCheck(self, lines, start_errors, end_errors): @@ -279,12 +279,12 @@ class CpplintTestBase(unittest.TestCase) def doTestBlankLinesCheck(self, lines, start_errors, end_errors, extension): error_collector = ErrorCollector(self.assert_) cpplint.ProcessFileData('foo.' + extension, extension, lines, error_collector) - self.assertEquals( + self.assertEqual( start_errors, error_collector.Results().count( 'Redundant blank line at the start of a code block ' 'should be deleted. [whitespace/blank_line] [2]')) - self.assertEquals( + self.assertEqual( end_errors, error_collector.Results().count( 'Redundant blank line at the end of a code block ' @@ -311,7 +311,7 @@ class CpplintTest(CpplintTestBase): '} // namespace Test'] results = self.GetNamespaceResults(lines) - self.assertEquals(results, 'Do not indent within a namespace ' + self.assertEqual(results, 'Do not indent within a namespace ' ' [runtime/indentation_namespace] [4]') def testNameSpaceIndentationForClass(self): @@ -322,7 +322,7 @@ class CpplintTest(CpplintTestBase): '} // namespace Test'] results = self.GetNamespaceResults(lines) - self.assertEquals(results, 'Do not indent within a namespace ' + self.assertEqual(results, 'Do not indent within a namespace ' ' [runtime/indentation_namespace] [4]') def testNameSpaceIndentationNoError(self): @@ -331,7 +331,7 @@ class CpplintTest(CpplintTestBase): '} // namespace Test'] results = self.GetNamespaceResults(lines) - self.assertEquals(results, '') + self.assertEqual(results, '') def testWhitespaceBeforeNamespace(self): lines = [' namespace Test {', @@ -339,7 +339,7 @@ class CpplintTest(CpplintTestBase): ' } // namespace Test'] results = self.GetNamespaceResults(lines) - self.assertEquals(results, '') + self.assertEqual(results, '') def testFalsePositivesNoError(self): lines = ['namespace Test {', @@ -350,34 +350,34 @@ class CpplintTest(CpplintTestBase): '} // namespace Test'] results = self.GetNamespaceResults(lines) - self.assertEquals(results, '') + self.assertEqual(results, '') # Test get line width. def testGetLineWidth(self): - self.assertEquals(0, cpplint.GetLineWidth('')) - self.assertEquals(10, cpplint.GetLineWidth(unicode('x') * 10)) - self.assertEquals(16, cpplint.GetLineWidth(unicode_escape_decode('\u90fd|\u9053|\u5e9c|\u770c|\u652f\u5e81'))) - self.assertEquals(16, cpplint.GetLineWidth(u'都|道|府|県|支庁')) - self.assertEquals(5 + 13 + 9, cpplint.GetLineWidth( + self.assertEqual(0, cpplint.GetLineWidth('')) + self.assertEqual(10, cpplint.GetLineWidth(unicode('x') * 10)) + self.assertEqual(16, cpplint.GetLineWidth(unicode_escape_decode('\u90fd|\u9053|\u5e9c|\u770c|\u652f\u5e81'))) + self.assertEqual(16, cpplint.GetLineWidth(u'都|道|府|県|支庁')) + self.assertEqual(5 + 13 + 9, cpplint.GetLineWidth( u'd𝐱/dt' + u'f : t ⨯ 𝐱 → ℝ' + u't ⨯ 𝐱 → ℝ')) def testGetTextInside(self): - self.assertEquals('', cpplint._GetTextInside('fun()', r'fun\(')) - self.assertEquals('x, y', cpplint._GetTextInside('f(x, y)', r'f\(')) - self.assertEquals('a(), b(c())', cpplint._GetTextInside( + self.assertEqual('', cpplint._GetTextInside('fun()', r'fun\(')) + self.assertEqual('x, y', cpplint._GetTextInside('f(x, y)', r'f\(')) + self.assertEqual('a(), b(c())', cpplint._GetTextInside( 'printf(a(), b(c()))', r'printf\(')) - self.assertEquals('x, y{}', cpplint._GetTextInside('f[x, y{}]', r'f\[')) - self.assertEquals(None, cpplint._GetTextInside('f[a, b(}]', r'f\[')) - self.assertEquals(None, cpplint._GetTextInside('f[x, y]', r'f\(')) - self.assertEquals('y, h(z, (a + b))', cpplint._GetTextInside( + self.assertEqual('x, y{}', cpplint._GetTextInside('f[x, y{}]', r'f\[')) + self.assertEqual(None, cpplint._GetTextInside('f[a, b(}]', r'f\[')) + self.assertEqual(None, cpplint._GetTextInside('f[x, y]', r'f\(')) + self.assertEqual('y, h(z, (a + b))', cpplint._GetTextInside( 'f(x, g(y, h(z, (a + b))))', r'g\(')) - self.assertEquals('f(f(x))', cpplint._GetTextInside('f(f(f(x)))', r'f\(')) + self.assertEqual('f(f(x))', cpplint._GetTextInside('f(f(f(x)))', r'f\(')) # Supports multiple lines. - self.assertEquals('\n return loop(x);\n', + self.assertEqual('\n return loop(x);\n', cpplint._GetTextInside( 'int loop(int x) {\n return loop(x);\n}\n', r'\{')) # '^' matches the beginning of each line. - self.assertEquals('x, y', + self.assertEqual('x, y', cpplint._GetTextInside( '#include "inl.h" // skip #define\n' '#define A2(x, y) a_inl_(x, y, __LINE__)\n' @@ -385,23 +385,23 @@ class CpplintTest(CpplintTestBase): r'^\s*#define\s*\w+\(')) def testFindNextMultiLineCommentStart(self): - self.assertEquals(1, cpplint.FindNextMultiLineCommentStart([''], 0)) + self.assertEqual(1, cpplint.FindNextMultiLineCommentStart([''], 0)) lines = ['a', 'b', '/* c'] - self.assertEquals(2, cpplint.FindNextMultiLineCommentStart(lines, 0)) + self.assertEqual(2, cpplint.FindNextMultiLineCommentStart(lines, 0)) lines = ['char a[] = "/*";'] # not recognized as comment. - self.assertEquals(1, cpplint.FindNextMultiLineCommentStart(lines, 0)) + self.assertEqual(1, cpplint.FindNextMultiLineCommentStart(lines, 0)) def testFindNextMultiLineCommentEnd(self): - self.assertEquals(1, cpplint.FindNextMultiLineCommentEnd([''], 0)) + self.assertEqual(1, cpplint.FindNextMultiLineCommentEnd([''], 0)) lines = ['a', 'b', ' c */'] - self.assertEquals(2, cpplint.FindNextMultiLineCommentEnd(lines, 0)) + self.assertEqual(2, cpplint.FindNextMultiLineCommentEnd(lines, 0)) def testRemoveMultiLineCommentsFromRange(self): lines = ['a', ' /* comment ', ' * still comment', ' comment */ ', 'b'] cpplint.RemoveMultiLineCommentsFromRange(lines, 1, 4) - self.assertEquals(['a', '/**/', '/**/', '/**/', 'b'], lines) + self.assertEqual(['a', '/**/', '/**/', '/**/', 'b'], lines) def testSpacesAtEndOfLine(self): self.TestLint( @@ -516,7 +516,7 @@ class CpplintTest(CpplintTestBase): '// ./command' + (' -verbose' * 80), ''], error_collector) - self.assertEquals('', error_collector.Results()) + self.assertEqual('', error_collector.Results()) # LINT_C_FILE silences cast warnings for entire file. error_collector = ErrorCollector(self.assert_) cpplint.ProcessFileData('test.h', 'h', @@ -526,7 +526,7 @@ class CpplintTest(CpplintTestBase): '// LINT_C_FILE', ''], error_collector) - self.assertEquals('', error_collector.Results()) + self.assertEqual('', error_collector.Results()) # Vim modes silence cast warnings for entire file. for modeline in ['vi:filetype=c', 'vi:sw=8 filetype=c', @@ -562,7 +562,7 @@ class CpplintTest(CpplintTestBase): '*/', ''], error_collector) - self.assertEquals('', error_collector.Results()) + self.assertEqual('', error_collector.Results()) # LINT_KERNEL_FILE silences whitespace/tab warnings for entire file. error_collector = ErrorCollector(self.assert_) cpplint.ProcessFileData('test.h', 'h', @@ -574,7 +574,7 @@ class CpplintTest(CpplintTestBase): '// LINT_KERNEL_FILE', ''], error_collector) - self.assertEquals('', error_collector.Results()) + self.assertEqual('', error_collector.Results()) # NOLINT, NOLINTNEXTLINE silences the readability/braces warning for "};". error_collector = ErrorCollector(self.assert_) cpplint.ProcessFileData('test.cc', 'cc', @@ -589,7 +589,7 @@ class CpplintTest(CpplintTestBase): '// LINT_KERNEL_FILE', ''], error_collector) - self.assertEquals('', error_collector.Results()) + self.assertEqual('', error_collector.Results()) # Test Variable Declarations. def testVariableDeclarations(self): @@ -845,7 +845,7 @@ class CpplintTest(CpplintTestBase): ' bool(int)> F;', ''], error_collector) - self.assertEquals('', error_collector.Results()) + self.assertEqual('', error_collector.Results()) # Return types for function pointers self.TestLint('typedef bool(FunctionPointer)();', '') @@ -889,13 +889,13 @@ class CpplintTest(CpplintTestBase): 'MOCK_METHOD1(method4, int(bool));', 'const int kConstant = int(42);'], # true positive error_collector) - self.assertEquals( + self.assertEqual( 0, error_collector.Results().count( ('Using deprecated casting style. ' 'Use static_cast<bool>(...) instead ' '[readability/casting] [4]'))) - self.assertEquals( + self.assertEqual( 1, error_collector.Results().count( ('Using deprecated casting style. ' @@ -941,11 +941,11 @@ class CpplintTest(CpplintTestBase): def testIncludeWhatYouUseNoImplementationFiles(self): code = 'std::vector<int> foo;' for extension in ['h', 'hpp', 'hxx', 'h++', 'cuh']: - self.assertEquals('Add #include <vector> for vector<>' + self.assertEqual('Add #include <vector> for vector<>' ' [build/include_what_you_use] [4]', self.PerformIncludeWhatYouUse(code, 'foo.' + extension)) for extension in ['c', 'cc', 'cpp', 'cxx', 'c++', 'cu']: - self.assertEquals('', + self.assertEqual('', self.PerformIncludeWhatYouUse(code, 'foo.' + extension)) def testIncludeWhatYouUse(self): @@ -1166,7 +1166,7 @@ class CpplintTest(CpplintTestBase): '#include "blah/a.h"', filename='blah/a.cc', io=MockIo(mock_header_contents)) - self.assertEquals(message, '') + self.assertEqual(message, '') mock_header_contents = ['#include <set>'] message = self.PerformIncludeWhatYouUse( @@ -1174,7 +1174,7 @@ class CpplintTest(CpplintTestBase): std::set<int> foo;""", filename='blah/a.cc', io=MockIo(mock_header_contents)) - self.assertEquals(message, '') + self.assertEqual(message, '') # Make sure we can find the correct header file if the cc file seems to be # a temporary file generated by Emacs's flymake. @@ -1184,7 +1184,7 @@ class CpplintTest(CpplintTestBase): std::set<int> foo;""", filename='blah/a_flymake.cc', io=MockIo(mock_header_contents)) - self.assertEquals(message, 'Add #include <set> for set<> ' + self.assertEqual(message, 'Add #include <set> for set<> ' '[build/include_what_you_use] [4]') # If there's just a cc and the header can't be found then it's ok. @@ -1192,7 +1192,7 @@ class CpplintTest(CpplintTestBase): """#include "blah/a.h" std::set<int> foo;""", filename='blah/a.cc') - self.assertEquals(message, '') + self.assertEqual(message, '') # Make sure we find the headers with relative paths. mock_header_contents = [''] @@ -1201,46 +1201,46 @@ class CpplintTest(CpplintTestBase): std::set<int> foo;""" % os.path.basename(os.getcwd()), filename='a.cc', io=MockIo(mock_header_contents)) - self.assertEquals(message, 'Add #include <set> for set<> ' + self.assertEqual(message, 'Add #include <set> for set<> ' '[build/include_what_you_use] [4]') def testFilesBelongToSameModule(self): f = cpplint.FilesBelongToSameModule - self.assertEquals((True, ''), f('a.cc', 'a.h')) - self.assertEquals((True, ''), f('base/google.cc', 'base/google.h')) - self.assertEquals((True, ''), f('base/google_test.c', 'base/google.h')) - self.assertEquals((True, ''), f('base/google_test.cc', 'base/google.h')) - self.assertEquals((True, ''), f('base/google_test.cc', 'base/google.hpp')) - self.assertEquals((True, ''), f('base/google_test.cxx', 'base/google.hxx')) - self.assertEquals((True, ''), f('base/google_test.cpp', 'base/google.hpp')) - self.assertEquals((True, ''), f('base/google_test.c++', 'base/google.h++')) - self.assertEquals((True, ''), f('base/google_test.cu', 'base/google.cuh')) - self.assertEquals((True, ''), + self.assertEqual((True, ''), f('a.cc', 'a.h')) + self.assertEqual((True, ''), f('base/google.cc', 'base/google.h')) + self.assertEqual((True, ''), f('base/google_test.c', 'base/google.h')) + self.assertEqual((True, ''), f('base/google_test.cc', 'base/google.h')) + self.assertEqual((True, ''), f('base/google_test.cc', 'base/google.hpp')) + self.assertEqual((True, ''), f('base/google_test.cxx', 'base/google.hxx')) + self.assertEqual((True, ''), f('base/google_test.cpp', 'base/google.hpp')) + self.assertEqual((True, ''), f('base/google_test.c++', 'base/google.h++')) + self.assertEqual((True, ''), f('base/google_test.cu', 'base/google.cuh')) + self.assertEqual((True, ''), f('base/google_unittest.cc', 'base/google.h')) - self.assertEquals((True, ''), + self.assertEqual((True, ''), f('base/internal/google_unittest.cc', 'base/public/google.h')) - self.assertEquals((True, 'xxx/yyy/'), + self.assertEqual((True, 'xxx/yyy/'), f('xxx/yyy/base/internal/google_unittest.cc', 'base/public/google.h')) - self.assertEquals((True, 'xxx/yyy/'), + self.assertEqual((True, 'xxx/yyy/'), f('xxx/yyy/base/google_unittest.cc', 'base/public/google.h')) - self.assertEquals((True, ''), + self.assertEqual((True, ''), f('base/google_unittest.cc', 'base/google-inl.h')) - self.assertEquals((True, '/home/build/google3/'), + self.assertEqual((True, '/home/build/google3/'), f('/home/build/google3/base/google.cc', 'base/google.h')) - self.assertEquals((False, ''), + self.assertEqual((False, ''), f('/home/build/google3/base/google.cc', 'basu/google.h')) - self.assertEquals((False, ''), f('a.cc', 'b.h')) + self.assertEqual((False, ''), f('a.cc', 'b.h')) def testCleanseLine(self): - self.assertEquals('int foo = 0;', + self.assertEqual('int foo = 0;', cpplint.CleanseComments('int foo = 0; // danger!')) - self.assertEquals('int o = 0;', + self.assertEqual('int o = 0;', cpplint.CleanseComments('int /* foo */ o = 0;')) - self.assertEquals('foo(int a, int b);', + self.assertEqual('foo(int a, int b);', cpplint.CleanseComments('foo(int a /* abc */, int b);')) self.assertEqual('f(a, b);', cpplint.CleanseComments('f(a, /* name */ b);')) @@ -1378,7 +1378,7 @@ class CpplintTest(CpplintTestBase): ['const char* str = "This is a\\', ' multiline string.";'], error_collector) - self.assertEquals( + self.assertEqual( 2, # One per line. error_collector.ResultList().count(multiline_string_error_message)) @@ -1731,7 +1731,7 @@ class CpplintTest(CpplintTestBase): ' explicit Foo(const int arg, Args&&... args) {}', '};'], error_collector) - self.assertEquals(0, error_collector.ResultList().count( + 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_) @@ -1741,7 +1741,7 @@ class CpplintTest(CpplintTestBase): ' explicit Foo(Args&&... args) {}', '};'], error_collector) - self.assertEquals(0, error_collector.ResultList().count( + 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_) @@ -1751,7 +1751,7 @@ class CpplintTest(CpplintTestBase): ' Foo(const int arg, Args&&... args) {}', '};'], error_collector) - self.assertEquals(1, error_collector.ResultList().count( + self.assertEqual(1, error_collector.ResultList().count( 'Constructors callable with one argument should be marked explicit.' ' [runtime/explicit] [5]')) error_collector = ErrorCollector(self.assert_) @@ -1761,7 +1761,7 @@ class CpplintTest(CpplintTestBase): ' Foo(Args&&... args) {}', '};'], error_collector) - self.assertEquals(1, error_collector.ResultList().count( + self.assertEqual(1, error_collector.ResultList().count( 'Constructors callable with one argument should be marked explicit.' ' [runtime/explicit] [5]')) # Anything goes inside an assembly block @@ -1776,16 +1776,16 @@ class CpplintTest(CpplintTestBase): ' }', '}'], error_collector) - self.assertEquals( + self.assertEqual( 0, error_collector.ResultList().count( 'Extra space before ( in function call [whitespace/parens] [4]')) - self.assertEquals( + self.assertEqual( 0, error_collector.ResultList().count( 'Closing ) should be moved to the previous line ' '[whitespace/parens] [2]')) - self.assertEquals( + self.assertEqual( 0, error_collector.ResultList().count( 'Extra space before [ [whitespace/braces] [5]')) @@ -1888,7 +1888,7 @@ class CpplintTest(CpplintTestBase): ' LOCKS_EXCLUDED(lock) ' + virt_specifier + ';', ''], error_collector) - self.assertEquals( + self.assertEqual( [error_message, error_message, error_message], error_collector.Results()) @@ -1914,7 +1914,7 @@ class CpplintTest(CpplintTestBase): '}', ''], error_collector) - self.assertEquals('', error_collector.Results()) + self.assertEqual('', error_collector.Results()) self.TestLint('void Finalize(AnnotationProto *final) override;', '') @@ -2085,7 +2085,7 @@ class CpplintTest(CpplintTestBase): '};', ''], error_collector) - self.assertEquals( + self.assertEqual( ('%s should be the last thing in the class' % macro_name) + ' [readability/constructors] [3]', error_collector.Results()) @@ -2104,7 +2104,7 @@ class CpplintTest(CpplintTestBase): '};', ''], error_collector) - self.assertEquals( + self.assertEqual( ('%s should be the last thing in the class' % macro_name) + ' [readability/constructors] [3]', error_collector.Results()) @@ -2141,7 +2141,7 @@ class CpplintTest(CpplintTestBase): '}', ''], error_collector) - self.assertEquals('', error_collector.Results()) + self.assertEqual('', error_collector.Results()) # Brace usage def testBraces(self): @@ -2450,7 +2450,7 @@ class CpplintTest(CpplintTestBase): 'void f(int& q) {}', ''], error_collector) - self.assertEquals( + self.assertEqual( operand_error_message % 'int& q', error_collector.Results()) @@ -2496,7 +2496,7 @@ class CpplintTest(CpplintTestBase): ' initializer2_(a6 & b6) {}', ''], error_collector) - self.assertEquals('', error_collector.Results()) + self.assertEqual('', error_collector.Results()) # Multi-line references error_collector = ErrorCollector(self.assert_) @@ -2518,7 +2518,7 @@ class CpplintTest(CpplintTestBase): '}', ''], error_collector) - self.assertEquals( + self.assertEqual( [operand_error_message % 'Outer::Inner& nonconst_x', operand_error_message % 'Outer::Inner& nonconst_y', operand_error_message % 'Outer<int>::Inner& nonconst_z'], @@ -2538,7 +2538,7 @@ class CpplintTest(CpplintTestBase): '}', ''], error_collector.Results()) - self.assertEquals('', error_collector.Results()) + self.assertEqual('', error_collector.Results()) def testBraceAtBeginOfLine(self): self.TestLint('{', @@ -2567,7 +2567,7 @@ class CpplintTest(CpplintTestBase): '}', '#endif'], error_collector) - self.assertEquals(1, error_collector.Results().count( + self.assertEqual(1, error_collector.Results().count( '{ should almost always be at the end of the previous line' ' [whitespace/braces] [4]')) @@ -3079,7 +3079,7 @@ class CpplintTest(CpplintTestBase): 'static_member_variable5;', ''], error_collector) - self.assertEquals(error_collector.Results(), + self.assertEqual(error_collector.Results(), [error_msg % 'const char Class::static_member_variable1', error_msg % 'const char Class::static_member_variable2', error_msg % 'const char Class::static_member_variable3', @@ -3210,7 +3210,7 @@ class CpplintTest(CpplintTestBase): error_collector = ErrorCollector(self.assert_) cpplint.ProcessFileData('foo.cc', 'cc', lines, error_collector) # The warning appears only once. - self.assertEquals( + self.assertEqual( 1, error_collector.Results().count( 'Do not use namespace using-directives. ' @@ -3234,7 +3234,7 @@ class CpplintTest(CpplintTestBase): cpplint.ProcessFileData('foo.cc', 'cc', data.split('\n'), error_collector) # The warning appears only once. - self.assertEquals( + self.assertEqual( int(is_missing_eof), error_collector.Results().count( 'Could not find a newline character at the end of the file.' @@ -3255,7 +3255,7 @@ class CpplintTest(CpplintTestBase): unidata, error_collector) # The warning appears only once. - self.assertEquals( + self.assertEqual( int(has_invalid_utf8), error_collector.Results().count( 'Line contains invalid UTF-8' @@ -3275,7 +3275,7 @@ class CpplintTest(CpplintTestBase): cpplint.ProcessFileData('nul.cc', 'cc', ['// Copyright 2014 Your Company.', '\0', ''], error_collector) - self.assertEquals( + self.assertEqual( error_collector.Results(), 'Line contains NUL byte. [readability/nul] [5]') @@ -3293,7 +3293,7 @@ class CpplintTest(CpplintTestBase): unidata, ''], error_collector) - self.assertEquals( + self.assertEqual( error_collector.Results(), ['Line contains invalid UTF-8 (or Unicode replacement character).' ' [readability/utf8] [5]', @@ -3343,7 +3343,7 @@ class CpplintTest(CpplintTestBase): '', '', '', '', '}'], error_collector) - self.assertEquals(0, error_collector.Results().count( + self.assertEqual(0, error_collector.Results().count( 'Redundant blank line at the end of a code block should be deleted.' ' [whitespace/blank_line] [3]')) @@ -3360,7 +3360,7 @@ class CpplintTest(CpplintTestBase): '', # Warning on this line '}'], error_collector) - self.assertEquals(1, error_collector.Results().count( + self.assertEqual(1, error_collector.Results().count( 'Redundant blank line at the end of a code block should be deleted.' ' [whitespace/blank_line] [3]')) @@ -3373,10 +3373,10 @@ class CpplintTest(CpplintTestBase): '', '}'], error_collector) - self.assertEquals(0, error_collector.Results().count( + self.assertEqual(0, error_collector.Results().count( 'Redundant blank line at the start of a code block should be deleted.' ' [whitespace/blank_line] [2]')) - self.assertEquals(0, error_collector.Results().count( + self.assertEqual(0, error_collector.Results().count( 'Redundant blank line at the end of a code block should be deleted.' ' [whitespace/blank_line] [3]')) @@ -3409,10 +3409,10 @@ class CpplintTest(CpplintTestBase): ' int a;\\', '};'], error_collector) - self.assertEquals(2, error_collector.Results().count( + self.assertEqual(2, error_collector.Results().count( '"private:" should be preceded by a blank line' ' [whitespace/blank_line] [3]')) - self.assertEquals(1, error_collector.Results().count( + self.assertEqual(1, error_collector.Results().count( '"protected:" should be preceded by a blank line' ' [whitespace/blank_line] [3]')) @@ -3430,13 +3430,13 @@ class CpplintTest(CpplintTestBase): ' };', '};'], error_collector) - self.assertEquals(1, error_collector.Results().count( + self.assertEqual(1, error_collector.Results().count( 'Do not leave a blank line after "public:"' ' [whitespace/blank_line] [3]')) - self.assertEquals(1, error_collector.Results().count( + self.assertEqual(1, error_collector.Results().count( 'Do not leave a blank line after "protected:"' ' [whitespace/blank_line] [3]')) - self.assertEquals(1, error_collector.Results().count( + self.assertEqual(1, error_collector.Results().count( 'Do not leave a blank line after "private:"' ' [whitespace/blank_line] [3]')) @@ -3451,7 +3451,7 @@ class CpplintTest(CpplintTestBase): ')"};', ''], error_collector) - self.assertEquals('', error_collector.Results()) + self.assertEqual('', error_collector.Results()) def testElseOnSameLineAsClosingBraces(self): error_collector = ErrorCollector(self.assert_) @@ -3464,7 +3464,7 @@ class CpplintTest(CpplintTestBase): '', '}'], error_collector) - self.assertEquals(2, error_collector.Results().count( + self.assertEqual(2, error_collector.Results().count( 'An else should appear on the same line as the preceding }' ' [whitespace/newline] [4]')) @@ -3478,7 +3478,7 @@ class CpplintTest(CpplintTestBase): '', '}'], error_collector) - self.assertEquals(1, error_collector.Results().count( + self.assertEqual(1, error_collector.Results().count( 'An else should appear on the same line as the preceding }' ' [whitespace/newline] [4]')) @@ -3489,7 +3489,7 @@ class CpplintTest(CpplintTestBase): '}', 'else_function();'], error_collector) - self.assertEquals(0, error_collector.Results().count( + self.assertEqual(0, error_collector.Results().count( 'An else should appear on the same line as the preceding }' ' [whitespace/newline] [4]')) @@ -3502,7 +3502,7 @@ class CpplintTest(CpplintTestBase): '}', 'sum += MathUtil::SafeIntRound(x); x += 0.1;'], error_collector) - self.assertEquals(0, error_collector.Results().count( + self.assertEqual(0, error_collector.Results().count( 'More than one command on the same line [whitespace/newline] [0]')) old_verbose_level = cpplint._cpplint_state.verbose_level @@ -3521,7 +3521,7 @@ class CpplintTest(CpplintTestBase): '[](const int i) { return i; };'], error_collector) cpplint._cpplint_state.verbose_level = old_verbose_level - self.assertEquals(0, error_collector.Results().count( + self.assertEqual(0, error_collector.Results().count( 'More than one command on the same line [whitespace/newline] [0]')) error_collector = ErrorCollector(self.assert_) @@ -3533,7 +3533,7 @@ class CpplintTest(CpplintTestBase): '[](const int i) { return i > 0; });'], error_collector) cpplint._cpplint_state.verbose_level = old_verbose_level - self.assertEquals(0, error_collector.Results().count( + self.assertEqual(0, error_collector.Results().count( 'More than one command on the same line [whitespace/newline] [0]')) error_collector = ErrorCollector(self.assert_) @@ -3545,7 +3545,7 @@ class CpplintTest(CpplintTestBase): 'this->ReadUnlock(); });'], error_collector) cpplint._cpplint_state.verbose_level = old_verbose_level - self.assertEquals(0, error_collector.Results().count( + self.assertEqual(0, error_collector.Results().count( 'More than one command on the same line [whitespace/newline] [0]')) error_collector = ErrorCollector(self.assert_) @@ -3557,7 +3557,7 @@ class CpplintTest(CpplintTestBase): 'this->ReadUnlock(); }, object);'], error_collector) cpplint._cpplint_state.verbose_level = old_verbose_level - self.assertEquals(0, error_collector.Results().count( + self.assertEqual(0, error_collector.Results().count( 'More than one command on the same line [whitespace/newline] [0]')) def testEndOfNamespaceComments(self): @@ -3604,26 +3604,26 @@ class CpplintTest(CpplintTestBase): ['} /* namespace c_style. */ \\', ';'], error_collector) - self.assertEquals(1, error_collector.Results().count( + self.assertEqual(1, error_collector.Results().count( 'Namespace should be terminated with "// namespace expected"' ' [readability/namespace] [5]')) - self.assertEquals(1, error_collector.Results().count( + self.assertEqual(1, error_collector.Results().count( 'Namespace should be terminated with "// namespace outer"' ' [readability/namespace] [5]')) - self.assertEquals(1, error_collector.Results().count( + self.assertEqual(1, error_collector.Results().count( 'Namespace should be terminated with "// namespace nested"' ' [readability/namespace] [5]')) - self.assertEquals(3, error_collector.Results().count( + self.assertEqual(3, error_collector.Results().count( 'Anonymous namespace should be terminated with "// namespace"' ' [readability/namespace] [5]')) - self.assertEquals(2, error_collector.Results().count( + self.assertEqual(2, error_collector.Results().count( 'Anonymous namespace should be terminated with "// namespace" or' ' "// anonymous namespace"' ' [readability/namespace] [5]')) - self.assertEquals(1, error_collector.Results().count( + self.assertEqual(1, error_collector.Results().count( 'Namespace should be terminated with "// namespace missing_comment"' ' [readability/namespace] [5]')) - self.assertEquals(0, error_collector.Results().count( + self.assertEqual(0, error_collector.Results().count( 'Namespace should be terminated with "// namespace no_warning"' ' [readability/namespace] [5]')) @@ -4088,38 +4088,38 @@ class CpplintTest(CpplintTestBase): ['--filter=+a,b,-c']) self.assertRaises(SystemExit, cpplint.ParseArguments, ['--headers']) - self.assertEquals(['foo.cc'], cpplint.ParseArguments(['foo.cc'])) - self.assertEquals(old_output_format, cpplint._cpplint_state.output_format) - self.assertEquals(old_verbose_level, cpplint._cpplint_state.verbose_level) + self.assertEqual(['foo.cc'], cpplint.ParseArguments(['foo.cc'])) + self.assertEqual(old_output_format, cpplint._cpplint_state.output_format) + self.assertEqual(old_verbose_level, cpplint._cpplint_state.verbose_level) - self.assertEquals(['foo.cc'], + self.assertEqual(['foo.cc'], cpplint.ParseArguments(['--v=1', 'foo.cc'])) - self.assertEquals(1, cpplint._cpplint_state.verbose_level) - self.assertEquals(['foo.h'], + self.assertEqual(1, cpplint._cpplint_state.verbose_level) + self.assertEqual(['foo.h'], cpplint.ParseArguments(['--v=3', 'foo.h'])) - self.assertEquals(3, cpplint._cpplint_state.verbose_level) - self.assertEquals(['foo.cpp'], + self.assertEqual(3, cpplint._cpplint_state.verbose_level) + self.assertEqual(['foo.cpp'], cpplint.ParseArguments(['--verbose=5', 'foo.cpp'])) - self.assertEquals(5, cpplint._cpplint_state.verbose_level) + self.assertEqual(5, cpplint._cpplint_state.verbose_level) self.assertRaises(ValueError, cpplint.ParseArguments, ['--v=f', 'foo.cc']) - self.assertEquals(['foo.cc'], + self.assertEqual(['foo.cc'], cpplint.ParseArguments(['--output=emacs', 'foo.cc'])) - self.assertEquals('emacs', cpplint._cpplint_state.output_format) - self.assertEquals(['foo.h'], + self.assertEqual('emacs', cpplint._cpplint_state.output_format) + self.assertEqual(['foo.h'], cpplint.ParseArguments(['--output=vs7', 'foo.h'])) - self.assertEquals('vs7', cpplint._cpplint_state.output_format) + self.assertEqual('vs7', cpplint._cpplint_state.output_format) self.assertRaises(SystemExit, cpplint.ParseArguments, ['--output=blah', 'foo.cc']) filt = '-,+whitespace,-whitespace/indent' - self.assertEquals(['foo.h'], + self.assertEqual(['foo.h'], cpplint.ParseArguments(['--filter='+filt, 'foo.h'])) - self.assertEquals(['-', '+whitespace', '-whitespace/indent'], + self.assertEqual(['-', '+whitespace', '-whitespace/indent'], cpplint._cpplint_state.filters) - self.assertEquals(['foo.cc', 'foo.h'], + self.assertEqual(['foo.cc', 'foo.h'], cpplint.ParseArguments(['foo.cc', 'foo.h'])) cpplint._hpp_headers = old_headers @@ -4174,7 +4174,7 @@ class CpplintTest(CpplintTestBase): os.path.join('src', 'nested', 'three.cpp')] cpplint._excludes = None actual = cpplint.ParseArguments(['--recursive', 'one.cpp', 'src']) - self.assertEquals(set(expected), set(actual)) + self.assertEqual(set(expected), set(actual)) finally: os.chdir(working_dir) shutil.rmtree(temp_dir) @@ -4193,7 +4193,7 @@ class CpplintTest(CpplintTestBase): cpplint._excludes = None actual = cpplint.ParseArguments(['--recursive', '--extensions=cpp', 'one.cpp', 'src']) - self.assertEquals(set(expected), set(actual)) + self.assertEqual(set(expected), set(actual)) finally: os.chdir(working_dir) shutil.rmtree(temp_dir) @@ -4223,23 +4223,23 @@ class CpplintTest(CpplintTestBase): ] cpplint._excludes = None actual = cpplint.ParseArguments(['src']) - self.assertEquals(set(['src']), set(actual)) + self.assertEqual(set(['src']), set(actual)) cpplint._excludes = None actual = cpplint.ParseArguments(['--recursive', 'src']) - self.assertEquals(set(expected), set(actual)) + self.assertEqual(set(expected), set(actual)) expected = [os.path.join('src', 'one.cc')] cpplint._excludes = None actual = cpplint.ParseArguments(['--recursive', '--exclude=src{0}t*'.format(os.sep), 'src']) - self.assertEquals(set(expected), set(actual)) + self.assertEqual(set(expected), set(actual)) expected = [os.path.join('src', 'one.cc')] cpplint._excludes = None actual = cpplint.ParseArguments(['--recursive', '--exclude=src/two.cc', '--exclude=src/three.cc', 'src']) - self.assertEquals(set(expected), set(actual)) + self.assertEqual(set(expected), set(actual)) expected = set([ os.path.join('src2', 'one.cc'), @@ -4249,7 +4249,7 @@ class CpplintTest(CpplintTestBase): cpplint._excludes = None actual = cpplint.ParseArguments(['--recursive', '--exclude=src', '.']) - self.assertEquals(expected, set(actual)) + self.assertEqual(expected, set(actual)) finally: os.chdir(working_dir) shutil.rmtree(temp_dir) @@ -4262,7 +4262,7 @@ class CpplintTest(CpplintTestBase): '<testsuite errors="0" failures="0" name="cpplint" tests="1">' '<testcase name="passed" />' '</testsuite>') - self.assertEquals(expected, cpplint._cpplint_state.FormatJUnitXML()) + self.assertEqual(expected, cpplint._cpplint_state.FormatJUnitXML()) cpplint._cpplint_state._junit_errors = ['ErrMsg1'] cpplint._cpplint_state._junit_failures = [] @@ -4270,7 +4270,7 @@ class CpplintTest(CpplintTestBase): '<testsuite errors="1" failures="0" name="cpplint" tests="1">' '<testcase name="errors"><error>ErrMsg1</error></testcase>' '</testsuite>') - self.assertEquals(expected, cpplint._cpplint_state.FormatJUnitXML()) + self.assertEqual(expected, cpplint._cpplint_state.FormatJUnitXML()) cpplint._cpplint_state._junit_errors = ['ErrMsg1', 'ErrMsg2'] cpplint._cpplint_state._junit_failures = [] @@ -4278,7 +4278,7 @@ class CpplintTest(CpplintTestBase): '<testsuite errors="2" failures="0" name="cpplint" tests="2">' '<testcase name="errors"><error>ErrMsg1\nErrMsg2</error></testcase>' '</testsuite>') - self.assertEquals(expected, cpplint._cpplint_state.FormatJUnitXML()) + self.assertEqual(expected, cpplint._cpplint_state.FormatJUnitXML()) cpplint._cpplint_state._junit_errors = ['ErrMsg'] cpplint._cpplint_state._junit_failures = [ @@ -4288,7 +4288,7 @@ class CpplintTest(CpplintTestBase): '<testcase name="errors"><error>ErrMsg</error></testcase>' '<testcase name="File"><failure>5: FailMsg [category/subcategory] ' '[3]</failure></testcase></testsuite>') - self.assertEquals(expected, cpplint._cpplint_state.FormatJUnitXML()) + self.assertEqual(expected, cpplint._cpplint_state.FormatJUnitXML()) cpplint._cpplint_state._junit_errors = [] cpplint._cpplint_state._junit_failures = [ @@ -4301,7 +4301,7 @@ class CpplintTest(CpplintTestBase): ' [3]\n19: FailMsg3 [category/subcategory] [3]</failure></testcase>' '<testcase name="File2"><failure>99: FailMsg2 ' '[category/subcategory] [3]</failure></testcase></testsuite>') - self.assertEquals(expected, cpplint._cpplint_state.FormatJUnitXML()) + self.assertEqual(expected, cpplint._cpplint_state.FormatJUnitXML()) cpplint._cpplint_state._junit_errors = ['&</error>'] cpplint._cpplint_state._junit_failures = [ @@ -4312,16 +4312,16 @@ class CpplintTest(CpplintTestBase): '</testcase><testcase name="File1"><failure>5: ' '&</failure> [category/subcategory] [3]</failure>' '</testcase></testsuite>') - self.assertEquals(expected, cpplint._cpplint_state.FormatJUnitXML()) + self.assertEqual(expected, cpplint._cpplint_state.FormatJUnitXML()) finally: cpplint._cpplint_state._junit_errors = [] cpplint._cpplint_state._junit_failures = [] def testQuiet(self): - self.assertEquals(cpplint._cpplint_state.quiet, False) + self.assertEqual(cpplint._cpplint_state.quiet, False) cpplint.ParseArguments(['--quiet', 'one.cpp']) - self.assertEquals(cpplint._cpplint_state.quiet, True) + self.assertEqual(cpplint._cpplint_state.quiet, True) def testLineLength(self): old_line_length = cpplint._line_length @@ -4390,7 +4390,7 @@ class CpplintTest(CpplintTestBase): '#endif', ''], error_collector) - self.assertEquals( + self.assertEqual( ['"path/duplicate.h" already included at path/self.cc:3 ' '[build/include] [4]'], error_collector.ResultList()) @@ -4499,7 +4499,7 @@ class CpplintTest(CpplintTestBase): # No guard at all: expect one error. error_collector = ErrorCollector(self.assert_) cpplint.ProcessFileData(file_path, 'h', [], error_collector) - self.assertEquals( + self.assertEqual( 1, error_collector.ResultList().count( 'No #ifndef header guard found, suggested CPP variable is: %s' @@ -4512,13 +4512,13 @@ class CpplintTest(CpplintTestBase): ['// Copyright 2014 Your Company.', '// NOLINT(build/header_guard)', ''], error_collector) - self.assertEquals([], error_collector.ResultList()) + self.assertEqual([], error_collector.ResultList()) # Wrong guard error_collector = ErrorCollector(self.assert_) cpplint.ProcessFileData(file_path, 'h', ['#ifndef FOO_H', '#define FOO_H'], error_collector) - self.assertEquals( + self.assertEqual( 1, error_collector.ResultList().count( '#ifndef header guard has wrong style, please use: %s' @@ -4529,7 +4529,7 @@ class CpplintTest(CpplintTestBase): error_collector = ErrorCollector(self.assert_) cpplint.ProcessFileData(file_path, 'h', ['#ifndef %s' % expected_guard], error_collector) - self.assertEquals( + self.assertEqual( 1, error_collector.ResultList().count( 'No #ifndef header guard found, suggested CPP variable is: %s' @@ -4542,7 +4542,7 @@ class CpplintTest(CpplintTestBase): ['#ifndef %s' % expected_guard, '#define FOO_H'], error_collector) - self.assertEquals( + self.assertEqual( 1, error_collector.ResultList().count( 'No #ifndef header guard found, suggested CPP variable is: %s' @@ -4556,7 +4556,7 @@ class CpplintTest(CpplintTestBase): '#define %s' % expected_guard, ''], error_collector) - self.assertEquals( + self.assertEqual( 1, error_collector.ResultList().count( '#endif line should be "#endif // %s"' @@ -4570,7 +4570,7 @@ class CpplintTest(CpplintTestBase): '#define %s' % expected_guard, '#endif'], error_collector) - self.assertEquals( + self.assertEqual( 1, error_collector.ResultList().count( '#endif line should be "#endif // %s"' @@ -4584,7 +4584,7 @@ class CpplintTest(CpplintTestBase): '#define %s_' % expected_guard, '#endif'], error_collector) - self.assertEquals( + self.assertEqual( 1, error_collector.ResultList().count( '#endif line should be "#endif // %s"' @@ -4623,7 +4623,7 @@ class CpplintTest(CpplintTestBase): '#define %s_' % expected_guard, '#endif // %s_' % expected_guard], error_collector) - self.assertEquals( + self.assertEqual( 1, error_collector.ResultList().count( '#ifndef header guard has wrong style, please use: %s' @@ -4639,13 +4639,13 @@ class CpplintTest(CpplintTestBase): '#define FOO', '#endif // FOO'], error_collector) - self.assertEquals( + self.assertEqual( 1, error_collector.ResultList().count( '#ifndef header guard has wrong style, please use: %s' ' [build/header_guard] [5]' % expected_guard), error_collector.ResultList()) - self.assertEquals( + self.assertEqual( 1, error_collector.ResultList().count( '#endif line should be "#endif // %s"' @@ -4659,13 +4659,13 @@ class CpplintTest(CpplintTestBase): '#define FOO', '#endif // FOO NOLINT'], error_collector) - self.assertEquals( + self.assertEqual( 0, error_collector.ResultList().count( '#ifndef header guard has wrong style, please use: %s' ' [build/header_guard] [5]' % expected_guard), error_collector.ResultList()) - self.assertEquals( + self.assertEqual( 0, error_collector.ResultList().count( '#endif line should be "#endif // %s"' @@ -4678,7 +4678,7 @@ class CpplintTest(CpplintTestBase): cpplint.ProcessFileData(test_file, 'h', ['// Copyright 2014 Your Company.', ''], error_collector) - self.assertEquals( + self.assertEqual( 1, error_collector.ResultList().count( 'No #ifndef header guard found, suggested CPP variable is: %s' @@ -4694,13 +4694,13 @@ class CpplintTest(CpplintTestBase): '#define FOO', '#endif // FOO'], error_collector) - self.assertEquals( + self.assertEqual( 1, error_collector.ResultList().count( '#ifndef header guard has wrong style, please use: %s' ' [build/header_guard] [5]' % expected_guard), error_collector.ResultList()) - self.assertEquals( + self.assertEqual( 1, error_collector.ResultList().count( '#endif line should be "#endif // %s"' @@ -4712,7 +4712,7 @@ class CpplintTest(CpplintTestBase): cpplint.ProcessFileData('mydir/foo.h', 'h', ['// Copyright 2014 Your Company.', '#pragma once', ''], error_collector) - self.assertEquals([], error_collector.ResultList()) + self.assertEqual([], error_collector.ResultList()) def testBuildHeaderGuardWithRoot(self): temp_directory = os.path.realpath(tempfile.mkdtemp()) @@ -4743,7 +4743,7 @@ class CpplintTest(CpplintTestBase): # when the root directory of the repository is properly deduced. return - self.assertEquals('CPPLINT_CPPLINT_TEST_HEADER_H_', + self.assertEqual('CPPLINT_CPPLINT_TEST_HEADER_H_', cpplint.GetHeaderGuardCPPVariable(file_path)) # # test --root flags: @@ -4753,7 +4753,7 @@ class CpplintTest(CpplintTestBase): # left-strip the header guard by using a root dir inside of the repo dir. # relative directory cpplint._root = 'cpplint' - self.assertEquals('CPPLINT_TEST_HEADER_H_', + self.assertEqual('CPPLINT_TEST_HEADER_H_', cpplint.GetHeaderGuardCPPVariable(file_path)) nested_header_directory = os.path.join(header_directory, "nested") @@ -4763,22 +4763,22 @@ class CpplintTest(CpplintTestBase): cpplint._root = os.path.join('cpplint', 'nested') actual = cpplint.GetHeaderGuardCPPVariable(nested_file_path) - self.assertEquals('CPPLINT_TEST_HEADER_H_', + self.assertEqual('CPPLINT_TEST_HEADER_H_', actual) # absolute directory # (note that CPPLINT.cfg root=setting is always made absolute) cpplint._root = header_directory - self.assertEquals('CPPLINT_TEST_HEADER_H_', + self.assertEqual('CPPLINT_TEST_HEADER_H_', cpplint.GetHeaderGuardCPPVariable(file_path)) cpplint._root = nested_header_directory - self.assertEquals('CPPLINT_TEST_HEADER_H_', + self.assertEqual('CPPLINT_TEST_HEADER_H_', cpplint.GetHeaderGuardCPPVariable(nested_file_path)) # --root flag is ignored if an non-existent directory is specified. cpplint._root = 'NON_EXISTENT_DIR' - self.assertEquals('CPPLINT_CPPLINT_TEST_HEADER_H_', + self.assertEqual('CPPLINT_CPPLINT_TEST_HEADER_H_', cpplint.GetHeaderGuardCPPVariable(file_path)) # prepend to the header guard by using a root dir that is more outer @@ -4795,7 +4795,7 @@ class CpplintTest(CpplintTestBase): # do not hardcode the 'styleguide' repository name, it could be anything. expected_prefix = re.sub(r'[^a-zA-Z0-9]', '_', styleguide_dir_name).upper() + '_' # do not have 'styleguide' repo in '/' - self.assertEquals('%sCPPLINT_CPPLINT_TEST_HEADER_H_' % (expected_prefix), + self.assertEqual('%sCPPLINT_CPPLINT_TEST_HEADER_H_' % (expected_prefix), cpplint.GetHeaderGuardCPPVariable(file_path)) # To run the 'relative path' tests, we must be in the directory of this test file. @@ -4806,13 +4806,13 @@ class CpplintTest(CpplintTestBase): styleguide_rel_path = os.path.relpath(styleguide_path, this_files_path) # '..' cpplint._root = styleguide_rel_path - self.assertEquals('CPPLINT_CPPLINT_TEST_HEADER_H_', + self.assertEqual('CPPLINT_CPPLINT_TEST_HEADER_H_', cpplint.GetHeaderGuardCPPVariable(file_path)) styleguide_rel_path = os.path.relpath(styleguide_parent_path, this_files_path) # '../..' cpplint._root = styleguide_rel_path - self.assertEquals('%sCPPLINT_CPPLINT_TEST_HEADER_H_' % (expected_prefix), + self.assertEqual('%sCPPLINT_CPPLINT_TEST_HEADER_H_' % (expected_prefix), cpplint.GetHeaderGuardCPPVariable(file_path)) cpplint._root = None @@ -4906,19 +4906,19 @@ class CpplintTest(CpplintTestBase): shutil.rmtree(temp_directory) def testPathSplitToList(self): - self.assertEquals([''], + self.assertEqual([''], cpplint.PathSplitToList(os.path.join(''))) - self.assertEquals(['.'], + self.assertEqual(['.'], cpplint.PathSplitToList(os.path.join('.'))) - self.assertEquals(['..'], + self.assertEqual(['..'], cpplint.PathSplitToList(os.path.join('..'))) - self.assertEquals(['..', 'a', 'b'], + self.assertEqual(['..', 'a', 'b'], cpplint.PathSplitToList(os.path.join('..', 'a', 'b'))) - self.assertEquals(['a', 'b', 'c', 'd'], + self.assertEqual(['a', 'b', 'c', 'd'], cpplint.PathSplitToList(os.path.join('a', 'b', 'c', 'd'))) def testBuildHeaderGuardWithRepository(self): @@ -4934,31 +4934,31 @@ class CpplintTest(CpplintTestBase): open(file_path, 'a').close() # search for .svn if _repository is not specified - self.assertEquals('TRUNK_CPPLINT_CPPLINT_TEST_HEADER_H_', + self.assertEqual('TRUNK_CPPLINT_CPPLINT_TEST_HEADER_H_', cpplint.GetHeaderGuardCPPVariable(file_path)) # use the provided repository root for header guards cpplint._repository = os.path.relpath(trunk_dir) - self.assertEquals('CPPLINT_CPPLINT_TEST_HEADER_H_', + self.assertEqual('CPPLINT_CPPLINT_TEST_HEADER_H_', cpplint.GetHeaderGuardCPPVariable(file_path)) cpplint._repository = os.path.abspath(trunk_dir) - self.assertEquals('CPPLINT_CPPLINT_TEST_HEADER_H_', + self.assertEqual('CPPLINT_CPPLINT_TEST_HEADER_H_', cpplint.GetHeaderGuardCPPVariable(file_path)) # ignore _repository if it doesnt exist cpplint._repository = os.path.join(temp_directory, 'NON_EXISTANT') - self.assertEquals('TRUNK_CPPLINT_CPPLINT_TEST_HEADER_H_', + self.assertEqual('TRUNK_CPPLINT_CPPLINT_TEST_HEADER_H_', cpplint.GetHeaderGuardCPPVariable(file_path)) # ignore _repository if it exists but file isn't in it cpplint._repository = os.path.relpath(temp_directory2) - self.assertEquals('TRUNK_CPPLINT_CPPLINT_TEST_HEADER_H_', + self.assertEqual('TRUNK_CPPLINT_CPPLINT_TEST_HEADER_H_', cpplint.GetHeaderGuardCPPVariable(file_path)) # _root should be relative to _repository cpplint._repository = os.path.relpath(trunk_dir) cpplint._root = 'cpplint' - self.assertEquals('CPPLINT_TEST_HEADER_H_', + self.assertEqual('CPPLINT_TEST_HEADER_H_', cpplint.GetHeaderGuardCPPVariable(file_path)) finally: @@ -4996,7 +4996,7 @@ class CpplintTest(CpplintTestBase): r'fprintf(file, "\(%d", value);', r'vsnprintf(buffer, sizeof(buffer), "\\\{%d", ap);'], error_collector) - self.assertEquals( + self.assertEqual( 4, error_collector.Results().count( '%, [, (, and { are undefined character escapes. Unescape them.' @@ -5011,7 +5011,7 @@ class CpplintTest(CpplintTestBase): r'printf(R"(\[%s)", R"(\])");', ''], error_collector) - self.assertEquals('', error_collector.Results()) + self.assertEqual('', error_collector.Results()) def testRuntimePrintfFormat(self): self.TestLint( @@ -5123,7 +5123,7 @@ class CpplintTest(CpplintTestBase): # There should be a copyright message in the first 10 lines error_collector = ErrorCollector(self.assert_) cpplint.ProcessFileData(file_path, 'cc', [], error_collector) - self.assertEquals( + self.assertEqual( 1, error_collector.ResultList().count(legal_copyright_message)) @@ -5132,7 +5132,7 @@ class CpplintTest(CpplintTestBase): file_path, 'cc', ['' for unused_i in range(10)] + [copyright_line], error_collector) - self.assertEquals( + self.assertEqual( 1, error_collector.ResultList().count(legal_copyright_message)) @@ -5182,7 +5182,7 @@ class Cxx11Test(CpplintTestBase): collector = ErrorCollector(self.assert_) cpplint.ProcessFileData(filename, extension, lines, collector) error_list = collector.ResultList() - self.assertEquals(count, len(error_list), error_list) + self.assertEqual(count, len(error_list), error_list) def TestCxx11Feature(self, code, expected_error): lines = code.split('\n') @@ -5190,7 +5190,7 @@ class Cxx11Test(CpplintTestBase): cpplint.RemoveMultiLineComments('foo.h', lines, collector) clean_lines = cpplint.CleansedLines(lines) cpplint.FlagCxx11Features('foo.cc', clean_lines, 0, collector) - self.assertEquals(expected_error, collector.Results()) + self.assertEqual(expected_error, collector.Results()) def testBlockedHeaders(self): self.TestCxx11Feature('#include <tr1/regex>', @@ -5248,7 +5248,7 @@ class Cxx14Test(CpplintTestBase): cpplint.RemoveMultiLineComments('foo.h', lines, collector) clean_lines = cpplint.CleansedLines(lines) cpplint.FlagCxx14Features('foo.cc', clean_lines, 0, collector) - self.assertEquals(expected_error, collector.Results()) + self.assertEqual(expected_error, collector.Results()) def testBlockedHeaders(self): self.TestCxx14Feature('#include <scoped_allocator>', @@ -5269,17 +5269,17 @@ class CleansedLinesTest(unittest.TestCas 'Line 5 "foo"'] clean_lines = cpplint.CleansedLines(lines) - self.assertEquals(lines, clean_lines.raw_lines) - self.assertEquals(5, clean_lines.NumLines()) + self.assertEqual(lines, clean_lines.raw_lines) + self.assertEqual(5, clean_lines.NumLines()) - self.assertEquals(['Line 1', + self.assertEqual(['Line 1', 'Line 2', 'Line 3', 'Line 4', 'Line 5 "foo"'], clean_lines.lines) - self.assertEquals(['Line 1', + self.assertEqual(['Line 1', 'Line 2', 'Line 3', 'Line 4', @@ -5288,48 +5288,48 @@ class CleansedLinesTest(unittest.TestCas def testInitEmpty(self): clean_lines = cpplint.CleansedLines([]) - self.assertEquals([], clean_lines.raw_lines) - self.assertEquals(0, clean_lines.NumLines()) + self.assertEqual([], clean_lines.raw_lines) + self.assertEqual(0, clean_lines.NumLines()) def testCollapseStrings(self): collapse = cpplint.CleansedLines._CollapseStrings - self.assertEquals('""', collapse('""')) # "" (empty) - self.assertEquals('"""', collapse('"""')) # """ (bad) - self.assertEquals('""', collapse('"xyz"')) # "xyz" (string) - self.assertEquals('""', collapse('"\\\""')) # "\"" (string) - self.assertEquals('""', collapse('"\'"')) # "'" (string) - self.assertEquals('"\"', collapse('"\"')) # "\" (bad) - self.assertEquals('""', collapse('"\\\\"')) # "\\" (string) - self.assertEquals('"', collapse('"\\\\\\"')) # "\\\" (bad) - self.assertEquals('""', collapse('"\\\\\\\\"')) # "\\\\" (string) - - self.assertEquals('\'\'', collapse('\'\'')) # '' (empty) - self.assertEquals('\'\'', collapse('\'a\'')) # 'a' (char) - self.assertEquals('\'\'', collapse('\'\\\'\'')) # '\'' (char) - self.assertEquals('\'', collapse('\'\\\'')) # '\' (bad) - self.assertEquals('', collapse('\\012')) # '\012' (char) - self.assertEquals('', collapse('\\xfF0')) # '\xfF0' (char) - self.assertEquals('', collapse('\\n')) # '\n' (char) - self.assertEquals(r'\#', collapse('\\#')) # '\#' (bad) - - self.assertEquals('"" + ""', collapse('"\'" + "\'"')) - self.assertEquals("'', ''", collapse("'\"', '\"'")) - self.assertEquals('""[0b10]', collapse('"a\'b"[0b1\'0]')) - - self.assertEquals('42', collapse("4'2")) - self.assertEquals('0b0101', collapse("0b0'1'0'1")) - self.assertEquals('1048576', collapse("1'048'576")) - self.assertEquals('0X100000', collapse("0X10'0000")) - self.assertEquals('0004000000', collapse("0'004'000'000")) - self.assertEquals('1.602176565e-19', collapse("1.602'176'565e-19")) - self.assertEquals('\'\' + 0xffff', collapse("'i' + 0xf'f'f'f")) - self.assertEquals('sizeof\'\' == 1', collapse("sizeof'x' == 1")) - self.assertEquals('0x.03p100', collapse('0x.0\'3p1\'0\'0')) - self.assertEquals('123.45', collapse('1\'23.4\'5')) + self.assertEqual('""', collapse('""')) # "" (empty) + self.assertEqual('"""', collapse('"""')) # """ (bad) + self.assertEqual('""', collapse('"xyz"')) # "xyz" (string) + self.assertEqual('""', collapse('"\\\""')) # "\"" (string) + self.assertEqual('""', collapse('"\'"')) # "'" (string) + self.assertEqual('"\"', collapse('"\"')) # "\" (bad) + self.assertEqual('""', collapse('"\\\\"')) # "\\" (string) + self.assertEqual('"', collapse('"\\\\\\"')) # "\\\" (bad) + self.assertEqual('""', collapse('"\\\\\\\\"')) # "\\\\" (string) + + self.assertEqual('\'\'', collapse('\'\'')) # '' (empty) + self.assertEqual('\'\'', collapse('\'a\'')) # 'a' (char) + self.assertEqual('\'\'', collapse('\'\\\'\'')) # '\'' (char) + self.assertEqual('\'', collapse('\'\\\'')) # '\' (bad) + self.assertEqual('', collapse('\\012')) # '\012' (char) + self.assertEqual('', collapse('\\xfF0')) # '\xfF0' (char) + self.assertEqual('', collapse('\\n')) # '\n' (char) + self.assertEqual(r'\#', collapse('\\#')) # '\#' (bad) + + self.assertEqual('"" + ""', collapse('"\'" + "\'"')) + self.assertEqual("'', ''", collapse("'\"', '\"'")) + self.assertEqual('""[0b10]', collapse('"a\'b"[0b1\'0]')) + + self.assertEqual('42', collapse("4'2")) + self.assertEqual('0b0101', collapse("0b0'1'0'1")) + self.assertEqual('1048576', collapse("1'048'576")) + self.assertEqual('0X100000', collapse("0X10'0000")) + self.assertEqual('0004000000', collapse("0'004'000'000")) + self.assertEqual('1.602176565e-19', collapse("1.602'176'565e-19")) + self.assertEqual('\'\' + 0xffff', collapse("'i' + 0xf'f'f'f")) + self.assertEqual('sizeof\'\' == 1', collapse("sizeof'x' == 1")) + self.assertEqual('0x.03p100', collapse('0x.0\'3p1\'0\'0')) + self.assertEqual('123.45', collapse('1\'23.4\'5')) - self.assertEquals('StringReplace(body, "", "");', + self.assertEqual('StringReplace(body, "", "");', collapse('StringReplace(body, "\\\\", "\\\\\\\\");')) - self.assertEquals('\'\' ""', + self.assertEqual('\'\' ""', collapse('\'"\' "foo"')) @@ -5446,7 +5446,7 @@ class OrderOfIncludesTest(CpplintTestBas classify_include(file_info('foo/foo.cc'), 'string', False)) - self.assertEquals(cpplint._OTHER_HEADER, + self.assertEqual(cpplint._OTHER_HEADER, classify_include(file_info('foo/foo.cc'), 'boost/any.hpp', True)) @@ -5662,7 +5662,7 @@ class CheckForFunctionLengthsTest(Cpplin code: C++ source code expected to generate a warning message. expected_message: Message expected to be generated by the C++ code. """ - self.assertEquals(expected_message, + self.assertEqual(expected_message, self.PerformFunctionLengthsCheck(code)) def TriggerLines(self, error_level): @@ -6040,7 +6040,7 @@ class CloseExpressionTest(unittest.TestC (18, 47, 20, 1)] for p in positions: (_, line, column) = cpplint.CloseExpression(self.lines, p[0], p[1]) - self.assertEquals((p[2], p[3]), (line, column)) + self.assertEqual((p[2], p[3]), (line, column)) def testReverseCloseExpression(self): # List of positions to test: @@ -6060,7 +6060,7 @@ class CloseExpressionTest(unittest.TestC (20, 0, 18, 47)] for p in positions: (_, line, column) = cpplint.ReverseCloseExpression(self.lines, p[0], p[1]) - self.assertEquals((p[2], p[3]), (line, column)) + self.assertEqual((p[2], p[3]), (line, column)) class NestingStateTest(unittest.TestCase): @@ -6077,155 +6077,155 @@ class NestingStateTest(unittest.TestCase def testEmpty(self): self.UpdateWithLines([]) - self.assertEquals(self.nesting_state.stack, []) + self.assertEqual(self.nesting_state.stack, []) def testNamespace(self): self.UpdateWithLines(['namespace {']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._NamespaceInfo)) self.assertTrue(self.nesting_state.stack[0].seen_open_brace) - self.assertEquals(self.nesting_state.stack[0].name, '') + self.assertEqual(self.nesting_state.stack[0].name, '') self.UpdateWithLines(['namespace outer { namespace inner']) - self.assertEquals(len(self.nesting_state.stack), 3) + self.assertEqual(len(self.nesting_state.stack), 3) self.assertTrue(self.nesting_state.stack[0].seen_open_brace) self.assertTrue(self.nesting_state.stack[1].seen_open_brace) self.assertFalse(self.nesting_state.stack[2].seen_open_brace) - self.assertEquals(self.nesting_state.stack[0].name, '') - self.assertEquals(self.nesting_state.stack[1].name, 'outer') - self.assertEquals(self.nesting_state.stack[2].name, 'inner') + self.assertEqual(self.nesting_state.stack[0].name, '') + self.assertEqual(self.nesting_state.stack[1].name, 'outer') + self.assertEqual(self.nesting_state.stack[2].name, 'inner') self.UpdateWithLines(['{']) self.assertTrue(self.nesting_state.stack[2].seen_open_brace) self.UpdateWithLines(['}', '}}']) - self.assertEquals(len(self.nesting_state.stack), 0) + self.assertEqual(len(self.nesting_state.stack), 0) def testDecoratedClass(self): self.UpdateWithLines(['class Decorated_123 API A {']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[0].name, 'A') + self.assertEqual(self.nesting_state.stack[0].name, 'A') self.assertFalse(self.nesting_state.stack[0].is_derived) - self.assertEquals(self.nesting_state.stack[0].class_indent, 0) + self.assertEqual(self.nesting_state.stack[0].class_indent, 0) self.UpdateWithLines(['}']) - self.assertEquals(len(self.nesting_state.stack), 0) + self.assertEqual(len(self.nesting_state.stack), 0) def testInnerClass(self): self.UpdateWithLines(['class A::B::C {']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[0].name, 'A::B::C') + self.assertEqual(self.nesting_state.stack[0].name, 'A::B::C') self.assertFalse(self.nesting_state.stack[0].is_derived) - self.assertEquals(self.nesting_state.stack[0].class_indent, 0) + self.assertEqual(self.nesting_state.stack[0].class_indent, 0) self.UpdateWithLines(['}']) - self.assertEquals(len(self.nesting_state.stack), 0) + self.assertEqual(len(self.nesting_state.stack), 0) def testClass(self): self.UpdateWithLines(['class A {']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[0].name, 'A') + self.assertEqual(self.nesting_state.stack[0].name, 'A') self.assertFalse(self.nesting_state.stack[0].is_derived) - self.assertEquals(self.nesting_state.stack[0].class_indent, 0) + self.assertEqual(self.nesting_state.stack[0].class_indent, 0) self.UpdateWithLines(['};', 'struct B : public A {']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[0].name, 'B') + self.assertEqual(self.nesting_state.stack[0].name, 'B') self.assertTrue(self.nesting_state.stack[0].is_derived) self.UpdateWithLines(['};', 'class C', ': public A {']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[0].name, 'C') + self.assertEqual(self.nesting_state.stack[0].name, 'C') self.assertTrue(self.nesting_state.stack[0].is_derived) self.UpdateWithLines(['};', 'template<T>']) - self.assertEquals(len(self.nesting_state.stack), 0) + self.assertEqual(len(self.nesting_state.stack), 0) self.UpdateWithLines(['class D {', ' class E {']) - self.assertEquals(len(self.nesting_state.stack), 2) + self.assertEqual(len(self.nesting_state.stack), 2) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[0].name, 'D') + self.assertEqual(self.nesting_state.stack[0].name, 'D') self.assertFalse(self.nesting_state.stack[0].is_derived) self.assertTrue(isinstance(self.nesting_state.stack[1], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[1].name, 'E') + self.assertEqual(self.nesting_state.stack[1].name, 'E') self.assertFalse(self.nesting_state.stack[1].is_derived) - self.assertEquals(self.nesting_state.stack[1].class_indent, 2) - self.assertEquals(self.nesting_state.InnermostClass().name, 'E') + self.assertEqual(self.nesting_state.stack[1].class_indent, 2) + self.assertEqual(self.nesting_state.InnermostClass().name, 'E') self.UpdateWithLines(['}', '}']) - self.assertEquals(len(self.nesting_state.stack), 0) + self.assertEqual(len(self.nesting_state.stack), 0) def testClassAccess(self): self.UpdateWithLines(['class A {']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[0].access, 'private') + self.assertEqual(self.nesting_state.stack[0].access, 'private') self.UpdateWithLines([' public:']) - self.assertEquals(self.nesting_state.stack[0].access, 'public') + self.assertEqual(self.nesting_state.stack[0].access, 'public') self.UpdateWithLines([' protracted:']) - self.assertEquals(self.nesting_state.stack[0].access, 'public') + self.assertEqual(self.nesting_state.stack[0].access, 'public') self.UpdateWithLines([' protected:']) - self.assertEquals(self.nesting_state.stack[0].access, 'protected') + self.assertEqual(self.nesting_state.stack[0].access, 'protected') self.UpdateWithLines([' private:']) - self.assertEquals(self.nesting_state.stack[0].access, 'private') + self.assertEqual(self.nesting_state.stack[0].access, 'private') self.UpdateWithLines([' struct B {']) - self.assertEquals(len(self.nesting_state.stack), 2) + self.assertEqual(len(self.nesting_state.stack), 2) self.assertTrue(isinstance(self.nesting_state.stack[1], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[1].access, 'public') - self.assertEquals(self.nesting_state.stack[0].access, 'private') + self.assertEqual(self.nesting_state.stack[1].access, 'public') + self.assertEqual(self.nesting_state.stack[0].access, 'private') self.UpdateWithLines([' protected :']) - self.assertEquals(self.nesting_state.stack[1].access, 'protected') - self.assertEquals(self.nesting_state.stack[0].access, 'private') + self.assertEqual(self.nesting_state.stack[1].access, 'protected') + self.assertEqual(self.nesting_state.stack[0].access, 'private') self.UpdateWithLines([' }', '}']) - self.assertEquals(len(self.nesting_state.stack), 0) + self.assertEqual(len(self.nesting_state.stack), 0) def testStruct(self): self.UpdateWithLines(['struct A {']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[0].name, 'A') + self.assertEqual(self.nesting_state.stack[0].name, 'A') self.assertFalse(self.nesting_state.stack[0].is_derived) self.UpdateWithLines(['}', 'void Func(struct B arg) {']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertFalse(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) self.UpdateWithLines(['}']) - self.assertEquals(len(self.nesting_state.stack), 0) + self.assertEqual(len(self.nesting_state.stack), 0) def testPreprocessor(self): - self.assertEquals(len(self.nesting_state.pp_stack), 0) + self.assertEqual(len(self.nesting_state.pp_stack), 0) self.UpdateWithLines(['#if MACRO1']) - self.assertEquals(len(self.nesting_state.pp_stack), 1) + self.assertEqual(len(self.nesting_state.pp_stack), 1) self.UpdateWithLines(['#endif']) - self.assertEquals(len(self.nesting_state.pp_stack), 0) + self.assertEqual(len(self.nesting_state.pp_stack), 0) self.UpdateWithLines(['#ifdef MACRO2']) - self.assertEquals(len(self.nesting_state.pp_stack), 1) + self.assertEqual(len(self.nesting_state.pp_stack), 1) self.UpdateWithLines(['#else']) - self.assertEquals(len(self.nesting_state.pp_stack), 1) + self.assertEqual(len(self.nesting_state.pp_stack), 1) self.UpdateWithLines(['#ifdef MACRO3']) - self.assertEquals(len(self.nesting_state.pp_stack), 2) + self.assertEqual(len(self.nesting_state.pp_stack), 2) self.UpdateWithLines(['#elif MACRO4']) - self.assertEquals(len(self.nesting_state.pp_stack), 2) + self.assertEqual(len(self.nesting_state.pp_stack), 2) self.UpdateWithLines(['#endif']) - self.assertEquals(len(self.nesting_state.pp_stack), 1) + self.assertEqual(len(self.nesting_state.pp_stack), 1) self.UpdateWithLines(['#endif']) - self.assertEquals(len(self.nesting_state.pp_stack), 0) + self.assertEqual(len(self.nesting_state.pp_stack), 0) self.UpdateWithLines(['#ifdef MACRO5', 'class A {', @@ -6234,162 +6234,162 @@ class NestingStateTest(unittest.TestCase '#else', 'class C {', '#endif']) - self.assertEquals(len(self.nesting_state.pp_stack), 0) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.pp_stack), 0) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[0].name, 'A') + self.assertEqual(self.nesting_state.stack[0].name, 'A') self.UpdateWithLines(['};']) - self.assertEquals(len(self.nesting_state.stack), 0) + self.assertEqual(len(self.nesting_state.stack), 0) self.UpdateWithLines(['class D', '#ifdef MACRO7']) - self.assertEquals(len(self.nesting_state.pp_stack), 1) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.pp_stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[0].name, 'D') + self.assertEqual(self.nesting_state.stack[0].name, 'D') self.assertFalse(self.nesting_state.stack[0].is_derived) self.UpdateWithLines(['#elif MACRO8', ': public E']) - self.assertEquals(len(self.nesting_state.stack), 1) - self.assertEquals(self.nesting_state.stack[0].name, 'D') + self.assertEqual(len(self.nesting_state.stack), 1) + self.assertEqual(self.nesting_state.stack[0].name, 'D') self.assertTrue(self.nesting_state.stack[0].is_derived) self.assertFalse(self.nesting_state.stack[0].seen_open_brace) self.UpdateWithLines(['#else', '{']) - self.assertEquals(len(self.nesting_state.stack), 1) - self.assertEquals(self.nesting_state.stack[0].name, 'D') + self.assertEqual(len(self.nesting_state.stack), 1) + self.assertEqual(self.nesting_state.stack[0].name, 'D') self.assertFalse(self.nesting_state.stack[0].is_derived) self.assertTrue(self.nesting_state.stack[0].seen_open_brace) self.UpdateWithLines(['#endif']) - self.assertEquals(len(self.nesting_state.pp_stack), 0) - self.assertEquals(len(self.nesting_state.stack), 1) - self.assertEquals(self.nesting_state.stack[0].name, 'D') + self.assertEqual(len(self.nesting_state.pp_stack), 0) + self.assertEqual(len(self.nesting_state.stack), 1) + self.assertEqual(self.nesting_state.stack[0].name, 'D') self.assertFalse(self.nesting_state.stack[0].is_derived) self.assertFalse(self.nesting_state.stack[0].seen_open_brace) self.UpdateWithLines([';']) - self.assertEquals(len(self.nesting_state.stack), 0) + self.assertEqual(len(self.nesting_state.stack), 0) def testTemplate(self): self.UpdateWithLines(['template <T,', ' class Arg1 = tmpl<T> >']) - self.assertEquals(len(self.nesting_state.stack), 0) + self.assertEqual(len(self.nesting_state.stack), 0) self.UpdateWithLines(['class A {']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[0].name, 'A') + self.assertEqual(self.nesting_state.stack[0].name, 'A') self.UpdateWithLines(['};', 'template <T,', ' template <typename, typename> class B>', 'class C']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[0].name, 'C') + self.assertEqual(self.nesting_state.stack[0].name, 'C') self.UpdateWithLines([';']) - self.assertEquals(len(self.nesting_state.stack), 0) + self.assertEqual(len(self.nesting_state.stack), 0) self.UpdateWithLines(['class D : public Tmpl<E>']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[0].name, 'D') + self.assertEqual(self.nesting_state.stack[0].name, 'D') self.UpdateWithLines(['{', '};']) - self.assertEquals(len(self.nesting_state.stack), 0) + self.assertEqual(len(self.nesting_state.stack), 0) self.UpdateWithLines(['template <class F,', ' class G,', ' class H,', ' typename I>', 'static void Func() {']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertFalse(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) self.UpdateWithLines(['}', 'template <class J> class K {']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[0].name, 'K') + self.assertEqual(self.nesting_state.stack[0].name, 'K') def testTemplateDefaultArg(self): self.UpdateWithLines([ 'template <class T, class D = default_delete<T>> class unique_ptr {']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(self.nesting_state.stack[0], isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) def testTemplateInnerClass(self): self.UpdateWithLines(['class A {', ' public:']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) self.UpdateWithLines([' template <class B>', ' class C<alloc<B> >', ' : public A {']) - self.assertEquals(len(self.nesting_state.stack), 2) + self.assertEqual(len(self.nesting_state.stack), 2) self.assertTrue(isinstance(self.nesting_state.stack[1], cpplint._ClassInfo)) def testArguments(self): self.UpdateWithLines(['class A {']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[0].name, 'A') - self.assertEquals(self.nesting_state.stack[-1].open_parentheses, 0) + self.assertEqual(self.nesting_state.stack[0].name, 'A') + self.assertEqual(self.nesting_state.stack[-1].open_parentheses, 0) self.UpdateWithLines([' void Func(', ' struct X arg1,']) - self.assertEquals(len(self.nesting_state.stack), 1) - self.assertEquals(self.nesting_state.stack[-1].open_parentheses, 1) + self.assertEqual(len(self.nesting_state.stack), 1) + self.assertEqual(self.nesting_state.stack[-1].open_parentheses, 1) self.UpdateWithLines([' struct X *arg2);']) - self.assertEquals(len(self.nesting_state.stack), 1) - self.assertEquals(self.nesting_state.stack[-1].open_parentheses, 0) + self.assertEqual(len(self.nesting_state.stack), 1) + self.assertEqual(self.nesting_state.stack[-1].open_parentheses, 0) self.UpdateWithLines(['};']) - self.assertEquals(len(self.nesting_state.stack), 0) + self.assertEqual(len(self.nesting_state.stack), 0) self.UpdateWithLines(['struct B {']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo)) - self.assertEquals(self.nesting_state.stack[0].name, 'B') + self.assertEqual(self.nesting_state.stack[0].name, 'B') self.UpdateWithLines(['#ifdef MACRO', ' void Func(', ' struct X arg1']) - self.assertEquals(len(self.nesting_state.stack), 1) - self.assertEquals(self.nesting_state.stack[-1].open_parentheses, 1) + self.assertEqual(len(self.nesting_state.stack), 1) + self.assertEqual(self.nesting_state.stack[-1].open_parentheses, 1) self.UpdateWithLines(['#else']) - self.assertEquals(len(self.nesting_state.stack), 1) - self.assertEquals(self.nesting_state.stack[-1].open_parentheses, 0) + self.assertEqual(len(self.nesting_state.stack), 1) + self.assertEqual(self.nesting_state.stack[-1].open_parentheses, 0) self.UpdateWithLines([' void Func(', ' struct X arg1']) - self.assertEquals(len(self.nesting_state.stack), 1) - self.assertEquals(self.nesting_state.stack[-1].open_parentheses, 1) + self.assertEqual(len(self.nesting_state.stack), 1) + self.assertEqual(self.nesting_state.stack[-1].open_parentheses, 1) self.UpdateWithLines(['#endif']) - self.assertEquals(len(self.nesting_state.stack), 1) - self.assertEquals(self.nesting_state.stack[-1].open_parentheses, 1) + self.assertEqual(len(self.nesting_state.stack), 1) + self.assertEqual(self.nesting_state.stack[-1].open_parentheses, 1) self.UpdateWithLines([' struct X *arg2);']) - self.assertEquals(len(self.nesting_state.stack), 1) - self.assertEquals(self.nesting_state.stack[-1].open_parentheses, 0) + self.assertEqual(len(self.nesting_state.stack), 1) + self.assertEqual(self.nesting_state.stack[-1].open_parentheses, 0) self.UpdateWithLines(['};']) - self.assertEquals(len(self.nesting_state.stack), 0) + self.assertEqual(len(self.nesting_state.stack), 0) def testInlineAssembly(self): self.UpdateWithLines(['void CopyRow_SSE2(const uint8* src, uint8* dst,', ' int count) {']) - self.assertEquals(len(self.nesting_state.stack), 1) - self.assertEquals(self.nesting_state.stack[-1].open_parentheses, 0) - self.assertEquals(self.nesting_state.stack[-1].inline_asm, cpplint._NO_ASM) + self.assertEqual(len(self.nesting_state.stack), 1) + self.assertEqual(self.nesting_state.stack[-1].open_parentheses, 0) + self.assertEqual(self.nesting_state.stack[-1].inline_asm, cpplint._NO_ASM) self.UpdateWithLines([' asm volatile (']) - self.assertEquals(len(self.nesting_state.stack), 1) - self.assertEquals(self.nesting_state.stack[-1].open_parentheses, 1) - self.assertEquals(self.nesting_state.stack[-1].inline_asm, + self.assertEqual(len(self.nesting_state.stack), 1) + self.assertEqual(self.nesting_state.stack[-1].open_parentheses, 1) + self.assertEqual(self.nesting_state.stack[-1].inline_asm, cpplint._INSIDE_ASM) self.UpdateWithLines([' "sub %0,%1 \\n"', @@ -6406,40 +6406,40 @@ class NestingStateTest(unittest.TestCase ' "+r"(count) // %2', ' :', ' : "memory", "cc"']) - self.assertEquals(len(self.nesting_state.stack), 1) - self.assertEquals(self.nesting_state.stack[-1].open_parentheses, 1) - self.assertEquals(self.nesting_state.stack[-1].inline_asm, + self.assertEqual(len(self.nesting_state.stack), 1) + self.assertEqual(self.nesting_state.stack[-1].open_parentheses, 1) + self.assertEqual(self.nesting_state.stack[-1].inline_asm, cpplint._INSIDE_ASM) self.UpdateWithLines(['#if defined(__SSE2__)', ' , "xmm0", "xmm1"']) - self.assertEquals(len(self.nesting_state.stack), 1) - self.assertEquals(self.nesting_state.stack[-1].open_parentheses, 1) - self.assertEquals(self.nesting_state.stack[-1].inline_asm, + self.assertEqual(len(self.nesting_state.stack), 1) + self.assertEqual(self.nesting_state.stack[-1].open_parentheses, 1) + self.assertEqual(self.nesting_state.stack[-1].inline_asm, cpplint._INSIDE_ASM) self.UpdateWithLines(['#endif']) - self.assertEquals(len(self.nesting_state.stack), 1) - self.assertEquals(self.nesting_state.stack[-1].open_parentheses, 1) - self.assertEquals(self.nesting_state.stack[-1].inline_asm, + self.assertEqual(len(self.nesting_state.stack), 1) + self.assertEqual(self.nesting_state.stack[-1].open_parentheses, 1) + self.assertEqual(self.nesting_state.stack[-1].inline_asm, cpplint._INSIDE_ASM) self.UpdateWithLines([' );']) - self.assertEquals(len(self.nesting_state.stack), 1) - self.assertEquals(self.nesting_state.stack[-1].open_parentheses, 0) - self.assertEquals(self.nesting_state.stack[-1].inline_asm, cpplint._END_ASM) + self.assertEqual(len(self.nesting_state.stack), 1) + self.assertEqual(self.nesting_state.stack[-1].open_parentheses, 0) + self.assertEqual(self.nesting_state.stack[-1].inline_asm, cpplint._END_ASM) self.UpdateWithLines(['__asm {']) - self.assertEquals(len(self.nesting_state.stack), 2) - self.assertEquals(self.nesting_state.stack[-1].open_parentheses, 0) - self.assertEquals(self.nesting_state.stack[-1].inline_asm, + self.assertEqual(len(self.nesting_state.stack), 2) + self.assertEqual(self.nesting_state.stack[-1].open_parentheses, 0) + self.assertEqual(self.nesting_state.stack[-1].inline_asm, cpplint._BLOCK_ASM) self.UpdateWithLines(['}']) - self.assertEquals(len(self.nesting_state.stack), 1) + self.assertEqual(len(self.nesting_state.stack), 1) self.UpdateWithLines(['}']) - self.assertEquals(len(self.nesting_state.stack), 0) + self.assertEqual(len(self.nesting_state.stack), 0) class QuietTest(unittest.TestCase): @@ -6476,7 +6476,7 @@ class QuietTest(unittest.TestCase): def testNonQuietWithErrors(self): # This will fail: the test header is missing a copyright and header guard. (return_code, output) = self._runCppLint() - self.assertEquals(1, return_code) + self.assertEqual(1, return_code) # Always-on behavior: Print error messages as they come up. self.assertIn("[legal/copyright]", output) self.assertIn("[build/header_guard]", output) @@ -6487,7 +6487,7 @@ class QuietTest(unittest.TestCase): def testQuietWithErrors(self): # When there are errors, behavior is identical to not passing --quiet. (return_code, output) = self._runCppLint('--quiet') - self.assertEquals(1, return_code) + self.assertEqual(1, return_code) self.assertIn("[legal/copyright]", output) self.assertIn("[build/header_guard]", output) # Even though --quiet was used, print these since there were errors. @@ -6499,7 +6499,7 @@ class QuietTest(unittest.TestCase): (return_code, output) = self._runCppLint('--filter=' + '-legal/copyright,' + '-build/header_guard') - self.assertEquals(0, return_code, output) + self.assertEqual(0, return_code, output) # No cpplint errors are printed since there were no errors. self.assertNotIn("[legal/copyright]", output) self.assertNotIn("[build/header_guard]", output) @@ -6513,7 +6513,7 @@ class QuietTest(unittest.TestCase): '--filter=' + '-legal/copyright,' + '-build/header_guard') - self.assertEquals(0, return_code, output) + self.assertEqual(0, return_code, output) # No cpplint errors are printed since there were no errors. self.assertNotIn("[legal/copyright]", output) self.assertNotIn("[build/header_guard]", output) @@ -6522,11 +6522,11 @@ class QuietTest(unittest.TestCase): self.assertNotIn("Done processing", output) self.assertNotIn("Total errors found:", output) # Output with no errors must be completely blank! - self.assertEquals("", output) + self.assertEqual("", output) # class FileFilterTest(unittest.TestCase): # def testFilterExcludedFiles(self): -# self.assertEquals([], _FilterExcludedFiles([])) +# self.assertEqual([], _FilterExcludedFiles([])) # pylint: disable=C6409 def setUp(): Index: cpplint-1.6.1/setup.py =================================================================== --- cpplint-1.6.1.orig/setup.py +++ cpplint-1.6.1/setup.py @@ -1,40 +1,7 @@ #! /usr/bin/env python - -from setuptools import setup, Command -from subprocess import check_call -from distutils.spawn import find_executable +from setuptools import setup import cpplint as cpplint -class Cmd(Command): - ''' - Superclass for other commands to run via setup.py, declared in setup.cfg. - These commands will auto-install setup_requires in a temporary folder. - ''' - user_options = [ - ('executable', 'e', 'The executable to use for the command') - ] - - def initialize_options(self): - self.executable = find_executable(self.executable) - - def finalize_options(self): - pass - - def execute(self, *k): - check_call((self.executable,) + k) - - -class Lint(Cmd): - '''run with python setup.py lint''' - description = 'Run linting of the code' - user_options = Cmd.user_options + [ - ('jobs', 'j', 'Use multiple processes to speed up the linting') - ] - executable = 'pylint' - - def run(self): - self.execute('cpplint.py') - # some pip versions bark on comments (e.g. on travis) def read_without_comments(filename): with open(filename) as f: @@ -80,7 +47,4 @@ setup(name='cpplint', extras_require={ 'test': test_required, 'dev': read_without_comments('dev-requirements') + test_required - }, - cmdclass={ - 'lint': Lint })
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