Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: third_party/logilab/logilab/astroid/brain/pynose.py

Issue 1920403002: [content/test/gpu] Run pylint check of gpu tests in unittest instead of PRESUBMIT (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update path to LICENSE.txt of logilab/README.chromium Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # copyright 2003-2015 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
3 #
4 # This file is part of astroid.
5 #
6 # astroid is free software: you can redistribute it and/or modify it
7 # under the terms of the GNU Lesser General Public License as published by the
8 # Free Software Foundation, either version 2.1 of the License, or (at your
9 # option) any later version.
10 #
11 # astroid is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14 # for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public License along
17 # with astroid. If not, see <http://www.gnu.org/licenses/>.
18
19 """Hooks for nose library."""
20
21 import re
22 import unittest
23
24 from astroid import List, MANAGER, register_module_extender
25 from astroid.builder import AstroidBuilder
26
27
28 def _pep8(name, caps=re.compile('([A-Z])')):
29 return caps.sub(lambda m: '_' + m.groups()[0].lower(), name)
30
31
32 def nose_transform():
33 """Custom transform for the nose.tools module."""
34
35 builder = AstroidBuilder(MANAGER)
36 stub = AstroidBuilder(MANAGER).string_build('''__all__ = []''')
37 unittest_module = builder.module_build(unittest.case)
38 case = unittest_module['TestCase']
39 all_entries = ['ok_', 'eq_']
40
41 for method_name, method in case.locals.items():
42 if method_name.startswith('assert') and '_' not in method_name:
43 pep8_name = _pep8(method_name)
44 all_entries.append(pep8_name)
45 stub[pep8_name] = method[0]
46
47 # Update the __all__ variable, since nose.tools
48 # does this manually with .append.
49 all_assign = stub['__all__'].parent
50 all_object = List(all_entries)
51 all_object.parent = all_assign
52 all_assign.value = all_object
53 return stub
54
55
56 register_module_extender(MANAGER, 'nose.tools.trivial', nose_transform)
OLDNEW
« no previous file with comments | « third_party/logilab/logilab/astroid/brain/py2stdlib.py ('k') | third_party/logilab/logilab/astroid/brain/pysix_moves.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698