Changeset 173
- Timestamp:
- 12/27/06 21:54:01 (2 years ago)
- Files:
-
- pybeast/trunk/Makefile (modified) (2 diffs, 1 prop)
- pybeast/trunk/ctest (modified) (1 prop)
- pybeast/trunk/ctest/Makefile (modified) (1 diff, 1 prop)
- pybeast/trunk/ctest/__init__.py (added)
- pybeast/trunk/dtest (modified) (1 prop)
- pybeast/trunk/dtest/Makefile (modified) (2 diffs, 1 prop)
- pybeast/trunk/dtest/__init__.py (modified) (1 diff)
- pybeast/trunk/dtest/py2py.py (modified) (1 diff)
- pybeast/trunk/src (modified) (1 prop)
- pybeast/trunk/src/Makefile (modified) (1 diff, 1 prop)
- pybeast/trunk/src/__init__.py (modified) (1 diff)
- pybeast/trunk/src/py2py.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pybeast/trunk/Makefile
- Property svn:keywords set to Id
r171 r173 1 # $Id : Makefile 79 2006-06-23 10:05:42Z akhavr$1 # $Id$ 2 2 # Copyright (C) 2001-2006 KDS Software Group http://www.kds.com.ua/ 3 3 … … 13 13 test: 14 14 $(MAKE) -C src build 15 $(MAKE) -C db test 16 $(MAKE) -C dtest 17 $(MAKE) -C ctest 15 $(MAKE) -C dtest test 16 $(MAKE) -C ctest test 18 17 19 18 clean: pybeast/trunk/ctest
- Property svn:ignore set to
*pass
- Property svn:ignore set to
pybeast/trunk/ctest/Makefile
- Property svn:keywords set to Id
r171 r173 1 # $Id : Makefile 79 2006-06-23 10:05:42Z akhavr$1 # $Id$ 2 2 # Copyright (C) 2001-2006 KDS Software Group 3 3 pybeast/trunk/dtest
- Property svn:ignore set to
*pass
*pyc
- Property svn:ignore set to
pybeast/trunk/dtest/Makefile
- Property svn:keywords set to Id
r171 r173 1 # $Id : Makefile 79 2006-06-23 10:05:42Z akhavr$1 # $Id$ 2 2 # Copyright (C) 2001-2006 KDS Software Group 3 3 … … 7 7 test_results=$(test_scripts:.py=.pass) 8 8 9 pythonpath=.. :../src9 pythonpath=.. 10 10 11 11 # Targets 12 12 13 .PHONY: build test clean 13 .PHONY: pylint build test clean 14 15 pylint: test 16 $(MAKE) -C .. pylint 14 17 15 18 test: build $(test_results) pybeast/trunk/dtest/__init__.py
r172 r173 2 2 # Copyright (C) 2006 KDS Software Group http://www.kds.com.ua 3 3 4 '''Developer tests for PyBeast - python mutation test checker 5 6 Copyright (C) 2006 KDS Software Group http://www.kds.com.ua 7 8 License: GPL v.2 9 ''' pybeast/trunk/dtest/py2py.py
r172 r173 2 2 # Copyright (C) 2006 KDS Software Group http://www.kds.com.ua 3 3 4 from src.py2py import Pep8Formatter 4 '''Test src.py2py''' 5 6 from src.py2py import Pep8Formatter, walk 5 7 6 8 import compiler 7 9 import unittest 8 10 9 class BoolOp(unittest.TestCase): 10 def testEmpty(self): 11 expr = '' 11 class Expr(unittest.TestCase): 12 '''Test src.py2py.Pep8Formatter expr handling ''' 13 14 def reformat_and_test(self, expr): 15 'Parse expr into ast and generate the code back. Compare and shout' 12 16 ast = compiler.parse(expr) 13 17 formatter = Pep8Formatter() 14 compiler.walk(ast, formatter) 18 walk(ast, formatter) 19 msg = 'Failed to reformat "%s" correctly.\n AST: %s\nResult: %s' 15 20 self.failUnless(formatter.dump()==expr, 16 'Failed to reformat "%s" correctly: %s' % ( 17 expr, formatter.dump())) 18 return 21 msg % (expr, ast, formatter.dump())) 22 23 def test_empty_expression(self): 24 'Test empty expression' 25 self.reformat_and_test('') 26 27 def test_bool_and(self): 28 'Test Bool And expression' 29 self.reformat_and_test('a = 1 and 2') 30 31 def test_bool_and_with_var(self): 32 'Test Bool And expression that includes variables' 33 self.reformat_and_test('a = a and 1') 34 35 def test_bool_or(self): 36 'Test Bool Or expression' 37 self.reformat_and_test('a = 1 or 2') 38 19 39 pass 20 40 21 if __name__=='__main__': unittest.main() 41 if __name__ == '__main__': 42 unittest.main() pybeast/trunk/src
- Property svn:ignore set to
*pyc
- Property svn:ignore set to
pybeast/trunk/src/Makefile
- Property svn:keywords set to Id
r171 r173 1 # $Id : Makefile 79 2006-06-23 10:05:42Z akhavr$1 # $Id$ 2 2 # Copyright (C) 2001-2006 KDS Software Group 3 3 4 4 build: 5 5 6 pylint: test 7 $(MAKE) -C .. pylint 8 6 9 test: 7 cd ..; $(MAKE)test10 $(MAKE) -C .. test 8 11 9 12 clean: pybeast/trunk/src/__init__.py
r172 r173 2 2 # Copyright (C) 2006 KDS Software Group http://www.kds.com.ua 3 3 4 '''PyBeast source code - python mutation test checker 5 6 Copyright (C) 2006 KDS Software Group http://www.kds.com.ua 7 8 License: GPL v.2 9 ''' pybeast/trunk/src/py2py.py
r172 r173 2 2 # Copyright (C) 2006 KDS Software Group http://www.kds.com.ua 3 3 4 '''Dump python AST into a source code''' 5 6 import compiler 7 import compiler.ast 8 4 9 class Pep8Formatter: 5 def dump(self): return '' 10 'Dump python AST into a PEP8-comforming source code' 11 12 def __init__(self): 13 self.code = '' 14 15 def visitAnd(self, node, walker): 16 'visit And node' 17 for subnode in node.nodes: 18 walker.dispatch(subnode) 19 self.code += ' and' 20 continue 21 self.code = self.code[:-4] 22 23 def visitAssName(self, node, *args): 24 'visit AssName node' 25 self.code += str(node.name) 26 if node.flags == 'OP_ASSIGN': 27 self.code += ' =' 28 return 29 30 def visitConst(self, node, *args): 31 'visit Const node' 32 self.code += ' ' + str(node.value) 33 34 def visitName(self, node, *args): 35 'visit Name node' 36 self.code += ' ' + str(node.name) 37 38 def visitOr(self, node, walker): 39 'visit Or node' 40 for subnode in node.nodes: 41 walker.dispatch(subnode) 42 self.code += ' or' 43 continue 44 self.code = self.code[:-3] 45 46 def dump(self): 47 'Return accumulated source code' 48 return self.code 6 49 pass 50 51 class ASTDeepWalker(compiler.visitor.ASTVisitor): 52 ''' 53 compiler.visitor.ASTWalker modified to allow processing nodes 54 to call back to continue depth-first traversal 55 ''' 56 57 def dispatch(self, node, *args): 58 'modified dispatch method' 59 self.node = node 60 klass = node.__class__ 61 meth = self._cache.get(klass, None) 62 if meth is None: 63 meth = getattr(self.visitor, 'visit' + klass.__name__, self.default) 64 self._cache[klass] = meth 65 return meth(node, self) 66 67 def walk(ast, formatter): 68 'Walk AST using supplied formatter and ASTDeepWalker' 69 compiler.walk(ast, formatter, ASTDeepWalker()) 70
