Esempio n. 1
0
import os
import sys

from NoneVisitor import *

dirName = '/Users/dillon/PythonWorkspace/'

x = NoneVisitor()
numExceptions = 0
for root, dirs, files in os.walk(dirName):
    for file in files:
        if file.endswith(".py"):
            path = os.path.join(root, file)
            print path
            try:
                parsedFile = ast.parse(open(path, "r").read())
                x.currentFile = path
                x.visit(parsedFile)
            except Exception, e:
                numExceptions += 1
                print 'Error: Could not parse file, exception: %s' % e

x.printErrors()
print ''
print 'Number of exceptions', numExceptions
Esempio n. 2
0
def twoErrors():
    fileName = './cases/Test2.py'
    parsedFile = ast.parse(open(fileName, 'r').read())
    x = NoneVisitor()
    x.visit(parsedFile)
    testAssert(x.numErrors() == 2, 'twoErrors')
Esempio n. 3
0
def setNone():
    fileName = './cases/Test3.py'
    parsedFile = ast.parse(open(fileName, 'r').read())
    x = NoneVisitor()
    x.visit(parsedFile)
    testAssert(x.numErrors() == 1, 'setNone')
Esempio n. 4
0
def basicTest():
    fileName = './cases/Test1.py'
    parsedFile = ast.parse(open(fileName, 'r').read())
    x = NoneVisitor()
    x.visit(parsedFile)
    testAssert(x.numErrors() == 1, 'basicTest')
Esempio n. 5
0
def countErrors(fileName):
    parsedFile = ast.parse(open(fileName, 'r').read())
    x = NoneVisitor()
    x.visit(parsedFile)
    return x.numErrors()