예제 #1
0
def main(argv):
    options, args = parser.parse_args(argv)

    script="./mce.py"
    if options.script:
        script = options.script

    if len(args) <= 1:
        do_these_regressions = ['*']
    else:
        do_these_regressions = args[1:]

    with untared_content("regression_test/alpha.tar.gz") as directory:
        test_data = os.path.join(directory, "alpha")
        passes = []
        fails = []
        
        for func, name, sha, args in alpha_tests:
            print("Starting regression {0} ({1})".format( name, args ))
            
            if any(fnmatch.fnmatch(name, x) for x in do_these_regressions):
                if options.profile:
                    wprint("Starting to profile to %s.profile" % name, sys.stderr)
                    os.environ['MCE_PROFILE'] = '%s.profile' % name
                try:
                    func(script, test_data, sha, args)
                except RegressionError as e:
                    fails.append( "Regression {0} failed: {1}".format(name, e) )
                    print(fails[-1])
                else:
                    passes.append( "Regression {0!r} complete.".format(name) )
                    print(passes[-1])
        
        print("{0} tests passed.".format(len(passes)))
        for line in fails: print(line);
예제 #2
0
    def __init__(self, filename=None):
        if filename is None:
            items_txt = self.items_txt
        else:
            try:
                with open(filename) as f:
                    items_txt = f.read()
            except Exception as e:
                print("Error reading items.txt: " + str(e))
                print("Using internal data.")
                items_txt = self.items_txt

        self.itemtypes = {}

        for line in items_txt.split("\n"):
            try:
                line = line.strip()
                if len(line) == 0: continue
                if line[0] == "#": continue
                if line[0] == "~":
                    continue
                    #groups
                stacksize = 64
                damagevalue = None
                maxdamage = 0

                fields = line.split()
                if len(fields) >= 4:
                    maxdamage = None
                    id, name, imagefile, imagecoords = fields[0:4]
                    if len(fields) > 4:
                        info = fields[4]
                        if info[0] == 'x':
                            stacksize = int(info[1:])
                        elif info[0] == '+':
                            maxdamage = int(info[1:])
                        else:
                            damagevalue = int(info)
                    id = int(id)
                    name = name.replace("_", " ")
                    imagecoords = imagecoords.split(",")

                    self.itemtypes[(id, damagevalue)] = ItemType(
                        id, name, imagefile, imagecoords, maxdamage,
                        damagevalue, stacksize)
            except Exception as e:
                print("Error reading line:" + str(e))
                print("Line: " + str(line))
                wprint()

        self.names = dict(
            (item.name, item.id) for item in self.itemtypes.itervalues())
예제 #3
0
파일: items.py 프로젝트: davispuh/pymclevel
    def __init__(self, filename = None):
        if filename is None:
            items_txt = self.items_txt
        else:
            try:
                with open(filename) as f:
                    items_txt = f.read()
            except Exception as e:
                print("Error reading items.txt: " + str(e));
                print("Using internal data.")
                items_txt = self.items_txt
            
        self.itemtypes = {};
        
        for line in items_txt.split("\n"):
            try:
                line = line.strip()
                if len(line) == 0: continue
                if line[0] == "#": continue;
                if line[0] == "~": continue; #groups
                stacksize = 64
                damagevalue = None
                maxdamage = 0

                fields = line.split();
                if len(fields) >= 4:
                    maxdamage = None;
                    id, name, imagefile, imagecoords = fields[0:4]
                    if len(fields) > 4:
                        info = fields[4]
                        if info[0] == 'x':
                            stacksize = int(info[1:])
                        elif info[0] == '+':
                            maxdamage = int(info[1:])
                        else:
                            damagevalue = int(info)
                    id = int(id);
                    name = name.replace("_", " ");
                    imagecoords = imagecoords.split(",");

                    self.itemtypes[(id, damagevalue)] = ItemType(id, name, imagefile, imagecoords, maxdamage, damagevalue, stacksize)
            except Exception as e:
                print("Error reading line:" + str(e))
                print("Line: " + str(line))
                wprint()

                
        self.names = dict((item.name, item.id) for item in self.itemtypes.itervalues())
예제 #4
0
def main(argv):
    options, args = parser.parse_args(argv)

    script = "./mce.py"
    if options.script:
        script = options.script

    if len(args) <= 1:
        do_these_regressions = ['*']
    else:
        do_these_regressions = args[1:]

    with untared_content("regression_test/alpha.tar.gz") as directory:
        test_data = os.path.join(directory, "alpha")
        passes = []
        fails = []

        for func, name, sha, args in alpha_tests:
            print("Starting regression {0} ({1})".format(name, args))

            if any(fnmatch.fnmatch(name, x) for x in do_these_regressions):
                if options.profile:
                    wprint("Starting to profile to %s.profile" % name,
                           sys.stderr)
                    os.environ['MCE_PROFILE'] = '%s.profile' % name
                try:
                    func(script, test_data, sha, args)
                except RegressionError as e:
                    fails.append("Regression {0} failed: {1}".format(name, e))
                    print(fails[-1])
                else:
                    passes.append("Regression {0!r} complete.".format(name))
                    print(passes[-1])

        print("{0} tests passed.".format(len(passes)))
        for line in fails:
            print(line)