<s> """<STR_LIT>""" <EOL> import os <EOL> import sys <EOL> import unittest <EOL> from openerp_conventions import OpenERPConventionsChecker <EOL> try : <EOL> import ast <EOL> except ImportError : <EOL> from flake8 . util import ast <EOL> def load_tests ( loader , tests , pattern ) : <EOL> return tests <EOL> class ConventionCheckTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> _file_name = None <EOL> _file_path = None <EOL> def init_tree ( self ) : <EOL> subclass_path = sys . modules [ self . __class__ . __module__ ] . __file__ <EOL> subclass_base_dir = os . path . dirname ( subclass_path ) <EOL> path = os . path . join ( os . path . abspath ( subclass_base_dir ) , <EOL> '<STR_LIT>' , self . _file_path ) <EOL> source = file ( path ) . read ( ) <EOL> return ast . parse ( source ) <EOL> def setUp ( self ) : <EOL> assert self . _file_name and self . _file_path <EOL> tree = self . init_tree ( ) <EOL> self . checker = OpenERPConventionsChecker ( tree , self . _file_name ) <EOL> self . checks = [ x for x in self . checker . check_tree ( tree ) ] <EOL> self . mapping = { } <EOL> for check in self . checks : <EOL> code = check [ <NUM_LIT:2> ] . split ( '<STR_LIT:U+0020>' ) [ <NUM_LIT:0> ] <EOL> vals = { '<STR_LIT:message>' : check [ <NUM_LIT:2> ] , <EOL> '<STR_LIT>' : check [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' : check [ <NUM_LIT:1> ] } <EOL> self . mapping [ code ] = vals <EOL> def check_code ( self , code , linenb , col = None ) : <EOL> self . assertIn ( code , self . mapping , <EOL> msg = '<STR_LIT>' % code ) <EOL> check = self . mapping [ code ] <EOL> self . assertEqual ( linenb , check [ '<STR_LIT>' ] , <EOL> msg = '<STR_LIT>' % ( check [ '<STR_LIT>' ] , <EOL> linenb ) ) <EOL> if col : <EOL> self . assertEqual ( col , check [ '<STR_LIT>' ] , <EOL> msg = '<STR_LIT>' % ( check [ '<STR_LIT>' ] , <EOL> col ) ) </s>
