[py-svn] r10300 - py/branch/py-collect/test/tkinter

jan at codespeak.net jan at codespeak.net
Mon Apr 4 18:59:17 CEST 2005


Author: jan
Date: Mon Apr  4 18:59:17 2005
New Revision: 10300

Added:
   py/branch/py-collect/test/tkinter/util.py
      - copied unchanged from r10295, py/branch/py-collect/test/tkinter/utils.py
Removed:
   py/branch/py-collect/test/tkinter/utils.py
Modified:
   py/branch/py-collect/test/tkinter/gui.py
   py/branch/py-collect/test/tkinter/guidriver.py
   py/branch/py-collect/test/tkinter/repository.py
   py/branch/py-collect/test/tkinter/tkgui.py
Log:
py/test/tkinter
moved utils.py to util.py


Modified: py/branch/py-collect/test/tkinter/gui.py
==============================================================================
--- py/branch/py-collect/test/tkinter/gui.py	(original)
+++ py/branch/py-collect/test/tkinter/gui.py	Mon Apr  4 18:59:17 2005
@@ -1,5 +1,5 @@
 from tktree import Tree, Node
-from utils import TestReport, Status, Null
+from util import TestReport, Status, Null
 from Tkinter import PhotoImage
 import py
 Item = py.test.Item

Modified: py/branch/py-collect/test/tkinter/guidriver.py
==============================================================================
--- py/branch/py-collect/test/tkinter/guidriver.py	(original)
+++ py/branch/py-collect/test/tkinter/guidriver.py	Mon Apr  4 18:59:17 2005
@@ -1,6 +1,6 @@
 
 import py
-from utils import Status, TestReport, Null
+from util import Status, TestReport, Null
 from py.__impl__.test.drive import Exit, exit, SimpleOutErrCapture
 
 import pprint

Modified: py/branch/py-collect/test/tkinter/repository.py
==============================================================================
--- py/branch/py-collect/test/tkinter/repository.py	(original)
+++ py/branch/py-collect/test/tkinter/repository.py	Mon Apr  4 18:59:17 2005
@@ -7,7 +7,7 @@
 import copy
 import time
 
-from utils import Null
+from util import Null
 from itertools import izip, count
 
 import UserDict

Modified: py/branch/py-collect/test/tkinter/tkgui.py
==============================================================================
--- py/branch/py-collect/test/tkinter/tkgui.py	(original)
+++ py/branch/py-collect/test/tkinter/tkgui.py	Mon Apr  4 18:59:17 2005
@@ -16,7 +16,7 @@
 
 import repository
 import utils
-from utils import TestReport, Status, Null
+from util import TestReport, Status, Null
 import gui
 
 

Deleted: /py/branch/py-collect/test/tkinter/utils.py
==============================================================================
--- /py/branch/py-collect/test/tkinter/utils.py	Mon Apr  4 18:59:17 2005
+++ (empty file)
@@ -1,247 +0,0 @@
-import types, string, sys
-import py
-from py.__impl__.test.report.text import out
-from py.__impl__.test.terminal import TerminalDriver
-
-class Null:
-    """ Null objects always and reliably "do nothing." """
-
-    def __init__(self, *args, **kwargs): pass
-    def __call__(self, *args, **kwargs): return self
-    def __repr__(self): return "Null()"
-    def __str__(self): return repr(self) + ' with id:' + str(id(self))
-    def __nonzero__(self): return 0
-
-    def __getattr__(self, name): return self
-    def __setattr__(self, name, value): return self
-    def __delattr__(self, name): return self
-
-    
-_NotExecuted = 'NotExecuted'
-_Passed = 'Passed'
-_Failed = 'Failed'
-_Skipped = 'Skipped'
-_ExceptionFailure = 'ExceptionFailure'
-
-class Status(object):
-
-    @classmethod
-    def NotExecuted(cls):
-        return cls('NotExecuted')
-    @classmethod
-    def Passed(cls):
-        return cls('Passed')
-    @classmethod
-    def Failed(cls):
-        return cls('Failed')
-    @classmethod
-    def Skipped(cls):
-        return cls('Skipped')
-    @classmethod
-    def ExceptionFailure(cls):
-        return cls(_ExceptionFailure)
-
-    ordered_list = [_NotExecuted,
-                    _Passed,
-                    _Skipped,
-                    _Failed,
-                    _ExceptionFailure]
-        
-    namemap = {
-        py.test.Item.Passed: _Passed,
-        py.test.Item.Skipped: _Skipped,
-        py.test.Item.Failed: _Failed,
-        py.test.Item.ExceptionFailure: _ExceptionFailure }
-    
-    def __init__(self, outcome_or_name = ''):
-        self.str = _NotExecuted
-        if isinstance(outcome_or_name, py.test.Collector.Outcome):
-            # hack
-            if isinstance(outcome_or_name, py.test.Item.ExceptionFailure):
-                self.str = self.namemap[py.test.Item.ExceptionFailure]
-            else:
-                for restype, name in self.namemap.items():
-                    if isinstance(outcome_or_name, restype):
-                        self.str = name
-        else:
-            if str(outcome_or_name) in self.ordered_list:
-                self.str = str(outcome_or_name)
-
-    def __repr__(self):
-        return 'Status("%s")' % self.str
-
-    def __str__(self):
-        return self.str
-
-    def update(self, status):
-        name_int_map = dict(
-            py.std.itertools.izip(self.ordered_list,
-                                  py.std.itertools.count()))
-        self.str = self.ordered_list[max([name_int_map[i] for i in (str(status), self.str)])]
-        
-    def __eq__(self, other):
-        return self.str == other.str
-
-    def __ne__(self, other):
-        return not self.__eq__(other)
-
-class OutBuffer(out.Out):
-
-    def __init__(self, fullwidth = 80 -1):
-        self.output = []
-        self.fullwidth = fullwidth
-
-    def line(self, s= ''):
-        self.output.append(str(s) + '\n')
-
-    def write(self, s):
-        self.output.append(str(s))
-
-    def getoutput(self):
-        return ''.join(self.output)
-
-    def rewrite(self, s=''):
-        self.write(s)
-
-   
-
-
-class TestReport(object):
-
-    template = {'time' : 0,
-                'label': 'Root',
-                'id': 'Root',
-                'full_id': ['Root'],
-                'status': Status.NotExecuted(),
-                'report': 'NoReport',
-                'error_report': '',
-                'finished': False,
-                'restart_params': None, # ('',('',))
-                }
-    @classmethod
-    def fromChannel(cls, kwdict):
-        if 'status' in kwdict:
-            kwdict['status'] = Status(kwdict['status'])
-        return cls(**kwdict)
-    
-
-    def __init__(self, **kwargs):
-        # copy status -> deepcopy
-        kwdict = py.std.copy.deepcopy(self.template)
-        kwdict.update(kwargs)
-        for key, value in kwdict.iteritems():
-            setattr(self, key, value)
-
-    def start(self, collector):
-        self.full_id = collector.listnames()
-        self.id = collector.name
-        if collector.getpathlineno(): # save for Null() in test_utils.py
-            fspath, lineno = collector.getpathlineno()
-            if lineno != sys.maxint:
-                str_append = ' [%s:%s]' % (fspath.basename, lineno)
-            else:
-                str_append = ' [%s]' % fspath.basename
-            self.label = collector.name + str_append
-
-        self.settime()
-        self.restart_params = (str(collector.listchain()[0].fspath),
-                               collector.listnames())
-        self.status = Status.NotExecuted()
-
-    def finish(self, collector, res, option = Null()):
-        self.settime()
-        if collector.getpathlineno(): # save for Null() in test_utils.py
-            fspath, lineno = collector.getpathlineno()
-            if lineno != sys.maxint:
-                str_append = ' [%s:%s] %0.2fsecs' % (fspath.basename, lineno, self.time)
-            else:
-                str_append = ' [%s] %0.2fsecs' % (fspath.basename, self.time)
-            self.label = collector.name + str_append
-        if res:
-            if Status(res) in (Status.Failed(), Status.ExceptionFailure()):
-                self.error_report = self.report_failed(option, collector, res)
-            elif Status(res) ==  Status.Skipped():
-                self.error_report = self.report_skipped(option, collector, res)
-            self.status.update(Status(res))
-        self.finished = True
-
-    def report_failed(self, option, item, res):
-        #XXX hack abuse of TerminalDriver
-        terminal = TerminalDriver(option)
-        out = OutBuffer()
-        terminal.out = out
-        terminal.repr_failure(item, res)
-        return out.getoutput()
-
-    def report_skipped(self,option, item, res):
-        texts = {}
-        tbindex = getattr(res, 'tbindex', -1)
-        raisingtb = res.excinfo.traceback[tbindex] 
-        fn = raisingtb.frame.code.path
-        lineno = raisingtb.lineno
-        d = texts.setdefault(res.excinfo.exconly(), {})
-        d[(fn,lineno)] = res
-        out = OutBuffer()
-        out.sep('_', 'reasons for skipped tests')
-        for text, dict in texts.items():
-            for (fn, lineno), res in dict.items(): 
-                out.line('Skipped in %s:%d' %(fn,lineno))
-            out.line("reason: %s" % text) 
-
-        return out.getoutput()
-        
-    def settime(self):
-        self.time = py.std.time.time() - self.time 
-
-    def toChannel(self):
-        ret = self.template.copy()
-        for key in ret.keys():
-            ret[key] = getattr(self, key, self.template[key])
-        ret['status'] = str(ret['status'])
-        return ret
-
-    def __str__(self):
-        return str(self.toChannel())
-
-    def __repr__(self):
-        return str(self)
-
-    def copy(self, **kwargs):
-        channel_dict = self.toChannel()
-        channel_dict.update(kwargs)
-        return TestReport.fromChannel(channel_dict)
-
-class TestFileWatcher:
-
-    def __init__(self, *paths):
-        self.paths = [py.path.local(path) for path in paths]
-        self.watchdict = dict()
-
-    def file_information(self, path):
-        try:
-            return path.stat().st_ctime
-        except:
-            return None
-
-    def check_files(self):
-        fil = py.path.checker(fnmatch='*.py')
-        rec = py.path.checker(dotfile=0)
-
-        files = []
-        for path in self.paths:
-            if path.check(file=1):
-                files.append(path)
-            else:
-                files.extend(path.visit(fil, rec))
-        newdict = dict(zip(files, [self.file_information(p) for p in files]))
-        files_deleted = [f for f in self.watchdict.keys() if not newdict.has_key(f)]
-        files_new = [f for f in newdict.keys() if not self.watchdict.has_key(f)]
-        files_changed = [f for f in newdict.keys() if self.watchdict.has_key(f) and newdict[f]!= self.watchdict[f]]
-        files_changed = files_new + files_changed
-
-        self.watchdict = newdict
-        return files_changed, files_deleted
-
-    def changed(self):
-        changed, deleted = self.check_files()
-        return changed != [] or deleted != []



More information about the pytest-commit mailing list