コード例 #1
0
ファイル: testing.py プロジェクト: simbha/GAE-appswell
 def __init__(self):
     TestResult.__init__(self)
     self.start_at = time.time()
     self.testSuccess = []
     self.all_tests = {}
     self.results_log = {}
     self.note_log = []
コード例 #2
0
ファイル: unittestpy.py プロジェクト: BobDohnal/fantasm
 def addError(self, test, err):
     TestResult.addError(self, test, err)
     
     err = self.formatErr(err)
     
     self.messages.testFailed(self.getTestName(test),
         message='Error', details=err)
コード例 #3
0
    def addError(self, test, err):
        testname = test.id().split(".")[-1]
        tb = err[2]
        stack = traceback.extract_tb(tb)
        for frame in stack:
            fname = frame[2]
            if fname == testname:
                if self._logging:
                    self._writeToStream("\tResult: ")
                self._writeToStream("Test ERROR", eColors.Yellow)
                break
            if fname == "setUp":
                if self._logging:
                    self._writeToStream("\tResult: ")
                self._writeToStream("SetUp ERROR", eColors.Yellow)
                break
            if fname == "tearDown":
                #If test succeded but tear down failed the result should
                #still be that the test failed. So it's my resposibility
                #to display thet only the 'test' part of the test passed. (Confused yet?)
                faults = chain(self.failures, self.errors)
                testFaults = ifilter(lambda item: item[0] == test, faults)
                hasFailed = (sum(1 for u in testFaults) > 0)
                if not hasFailed:
                    if self._logging:
                        self._writeToStream("\tResult: ")
                    self._writeToStream("PASSED", eColors.Green)

                self._writeToStream(", ")
                self._writeToStream("Tear Down ERROR", eColors.Yellow)
                break

        TestResult.addError(self, test, err)
コード例 #4
0
  def addError(self, test, err):
    TestResult.addError(self, test, err)

    err = self._exc_info_to_string(err, test)

    self.messages.testError(self.getTestName(test),
                            message='Error', details=err)
コード例 #5
0
    def addFailure(self, test, err, *k):
        TestResult.addFailure(self, test, err)

        err = self.formatErr(err)
        
        self.messages.testFailed(self.getTestName(test),
            message='Failure', details=err)
コード例 #6
0
ファイル: testrunner.py プロジェクト: mtdx/py-utils
 def addSkip(self, test, reason):
     TestResult.addSkip(self, test, reason)
     if self.verbose:
         self.stream.write("SKIPPED: %s [%s]%s" % (test, reason,
                                                   os.linesep))
         self.stream.flush()
     self.countcall()
コード例 #7
0
    def stopTest(self, test):
        stopTime = time.time()
        deltaTime = stopTime - self._startTime
        TestResult.stopTest(self, test)
        self.stream.write(' time="%.3f"' % deltaTime)
        self.stream.write('>')
        if self._lastWas != 'success':
            if self._lastWas == 'error':
                self.stream.write(self._errorsAndFailures)
            elif self._lastWas == 'failure':
                self.stream.write(self._errorsAndFailures)
            else:
                assert(False)

        seen = {}

        for assertion in test._extraAssertions:
            if not seen.has_key(assertion):
                self._addAssertion(assertion[:110]) # :110 avoids tl;dr TODO use a lexical truncator
                seen[assertion] = True

        self.stream.write('</testcase>')
        self._errorsAndFailures = ""

        if test._extraXML != '':
            self.stream.write(test._extraXML)
コード例 #8
0
ファイル: parunittest.py プロジェクト: eojons/gpaw-scme
 def stopTest(self, test):
     """Called when the given test has been run. If the stop flag was
     raised beforehand, will broadcast to raise flags for global stop."""
     stop_flags = np.empty(self.comm.size, dtype=bool)
     self.comm.all_gather(np.array([self.shouldStop]), stop_flags)
     self.shouldStop = stop_flags.any()
     TestResult.stopTest(self, test)
コード例 #9
0
    def addFailure(self, test, err):
        location = self.init_suite(test)
        self.current_failed = True
        TestResult.addFailure(self, test, err)

        error_value = smart_str(err[1])
        if not len(error_value):
            # means it's test function and we have to extract value from traceback
            error_value = self.find_error_value(err[2])

        self_find_first = self.find_first(error_value)
        self_find_second = self.find_second(error_value)
        quotes = ["'", '"']
        if (
            self_find_first[0] == self_find_first[-1]
            and self_find_first[0] in quotes
            and self_find_second[0] == self_find_second[-1]
            and self_find_second[0] in quotes
        ):
            # let's unescape strings to show sexy multiline diff in PyCharm.
            # By default all caret return chars are escaped by testing framework
            first = self._unescape(self_find_first)
            second = self._unescape(self_find_second)
        else:
            first = second = ""
        err = self._exc_info_to_string(err, test)

        self.messages.testStarted(self.getTestName(test), location=location)
        duration = self.__getDuration(test)
        self.messages.testFailed(
            self.getTestName(test), message="Failure", details=err, expected=first, actual=second, duration=duration
        )
コード例 #10
0
ファイル: plugin.py プロジェクト: kmanalo/nose-nicedots
 def addFailure(self, test, err):
     TestResult.addFailure(self, test, err)
     if self.showAll:
         self.stream.writeln("FAIL")
     elif self.dots:
         self.printError('FAIL', err, test)
         self.stream.flush()
コード例 #11
0
ファイル: unittestpy.py プロジェクト: curzona/teamcity-python
    def __init__(self, stream=sys.stdout):
        TestResult.__init__(self)

        self.output = stream
        self.test_started_datetime = None
        self.test_name = None

        self.createMessages()
コード例 #12
0
 def startTest(self, test):
     "Called before execute each test method."
     self.start_time = time.time()
     TestResult.startTest(self, test)
     
     if self.showAll:
         self.stream.write('  ' + self.getDescription(test))
         self.stream.write(" ... ")
コード例 #13
0
ファイル: test_support.py プロジェクト: jimmysitu/pyclewn
 def addSkip(self, test, reason):
     """Called when a test is skipped."""
     TestResult.addSkip(self, test, reason)
     if self.verbose:
         self.stream.write('skipped (%s)\n' % reason)
     else:
         self.stream.write('s')
         self.stream.flush()
コード例 #14
0
ファイル: test_support.py プロジェクト: jimmysitu/pyclewn
 def addError(self, test, err):
     """Called when an error has occurred."""
     TestResult.addError(self, test, err)
     if self.verbose:
         self.stream.write('ERROR\n')
     else:
         self.stream.write('E')
         self.stream.flush()
コード例 #15
0
ファイル: parunittest.py プロジェクト: eojons/gpaw-scme
 def __init__(self, comm=None):
     if comm is None:
         comm = world
     self.comm = comm
     self.outcomes = []
     self.last_errors = np.empty(self.comm.size, dtype=bool)
     self.last_failed = np.empty(self.comm.size, dtype=bool)
     TestResult.__init__(self)
コード例 #16
0
 def addFailure(self, test, err):
     TestResult.addFailure(self, test, err)
     exctype, value, dummy_tb = err
     error_xml = self.xml.createElement('failure')
     error_xml.setAttribute('type', '%s' % exctype)
     message_xml = self.xml.createTextNode('%s' % value)
     error_xml.appendChild(message_xml)
     self._testcase_xml.appendChild(error_xml)
コード例 #17
0
ファイル: DCTestResult.py プロジェクト: testmana2/test
 def __init__(self, parent):
     """
     Constructor
     
     @param parent The parent widget.
     """
     TestResult.__init__(self)
     self.parent = parent
コード例 #18
0
ファイル: test_support.py プロジェクト: jimmysitu/pyclewn
 def addSuccess(self, test):
     "Called when a test has completed successfully"
     TestResult.addSuccess(self, test)
     if self.verbose:
         self.stream.write('ok\n')
     else:
         self.stream.write('.')
         self.stream.flush()
コード例 #19
0
 def __init__(self, stream=sys.stdout, *args, **kwargs):
   TestResult.__init__(self)
   for arg, value in kwargs.items():
     setattr(self, arg, value)
   self.output = stream
   self.messages = TeamcityServiceMessages(self.output, prepend_linebreak=True)
   self.messages.testMatrixEntered()
   self.current_suite = None
コード例 #20
0
    def addError(self, test, err):
        location = self.init_suite(test)
        self.current_failed = True
        TestResult.addError(self, test, err)

        err = self._exc_info_to_string(err, test)

        self.messages.testStarted(self.getTestName(test), location=location)
        self.messages.testError(self.getTestName(test), message="Error", details=err, duration=self.__getDuration(test))
コード例 #21
0
 def __init__(self, xml, descriptions, verbosity):
     TestResult.__init__(self)
     self.xml = xml
     self.showAll = verbosity > 1
     self.dots = verbosity == 1
     self.descriptions = descriptions
     self._testsuites = {}
     self._testsuite_xml = None
     self._testcase_xml = None
コード例 #22
0
 def __init__(self, stream, descriptions, verbosity):
     TestResult.__init__(self)
     self.stream = _WritelnDecorator(stream)
     self.showAll = verbosity > 1
     self.descriptions = descriptions
     self._lastWas = 'success'
     self._errorsAndFailures = ""
     self._startTime = 0.0
     self.params=""
コード例 #23
0
 def startTest(self, test):
     """
     Method called at the start of a test.
     
     @param test Reference to the test object
     """
     TestResult.startTest(self, test)
     self.parent.write('%s%s\n' % (ResponseUTStartTest,
         unicode((unicode(test), test.shortDescription()))))
コード例 #24
0
 def startTest(self, test):
     """
     Method called at the start of a test.
     
     @param test Reference to the test object
     """
     TestResult.startTest(self, test)
     self.parent.write('{0}{1}\n'.format(ResponseUTStartTest,
         str((str(test), test.shortDescription()))))
コード例 #25
0
 def startTest(self, test):
     TestResult.startTest(self, test)
     # just one buffer for both stdout and stderr
     stdout_redirector.fp = self.outputBuffer
     stderr_redirector.fp = self.outputBuffer
     self.stdout0 = sys.stdout
     self.stderr0 = sys.stderr
     sys.stdout = stdout_redirector
     sys.stderr = stderr_redirector
コード例 #26
0
ファイル: subunitlogobserver.py プロジェクト: Almad/buildbot
 def __init__(self):
     buildstep.LogLineObserver.__init__(self)
     TestResult.__init__(self)
     try:
         from subunit import TestProtocolServer
     except ImportError:
         raise ImportError("subunit is not importable, but is required for "
             "SubunitLogObserver support.")
     self.protocol = TestProtocolServer(self, DiscardStream())
コード例 #27
0
ファイル: DCTestResult.py プロジェクト: paulmadore/Eric-IDE
 def addUnexpectedSuccess(self, test):
     """
     Public method called if a test succeeded expectedly.
     
     @param test reference to the test object
     """
     TestResult.addUnexpectedSuccess(self, test)
     self.parent.write('{0}{1}\n'.format(
         ResponseUTTestSucceededUnexpected,
         str((str(test), test.id()))))
コード例 #28
0
 def addError(self, test, err):
     TestResult.addError(self, test, err)
     if err[0] is KeyboardInterrupt:
         self.shouldStop = 1
     self._lastWas = 'error'
     self._errorsAndFailures += '<error type="%s">' % err[0].__name__
     for line in apply(traceback.format_exception, err):
        for l in string.split(line,"\n")[:-1]:
           self._errorsAndFailures += "%s" % l
     self._errorsAndFailures += "</error>"
コード例 #29
0
ファイル: __init__.py プロジェクト: alquerci/cyg-apt
    def __init__(self, result):
        """Constructor.

        @param result: TestResult The wrapped object
        """
        assert isinstance(result, TestResult);

        TestResult.__init__(self);

        self._result = result;
コード例 #30
0
 def addFailure(self, test, err):
     TestResult.addFailure(self, test, err)
     if err[0] is KeyboardInterrupt:
         self.shouldStop = 1
     self._lastWas = 'failure'
     self._errorsAndFailures += '<failure type="%s">' % err[0].__name__
     for line in apply(traceback.format_exception, err):
        for l in line.split("\n")[:-1]:
           self._errorsAndFailures += escape(l)
     self._errorsAndFailures += "</failure>"
コード例 #31
0
 def addFailure(self, test, err):
     TestResult.addFailure(self, test, err)
     self.issue()
コード例 #32
0
 def __init__(self, stream, descriptions):
     _TestResult.__init__(self)
     self.stream = stream
     self.descriptions = descriptions
コード例 #33
0
ファイル: runner.py プロジェクト: zhxfei/psutil
 def addSkip(self, test, reason):
     TestResult.addSkip(self, test, reason)
     self.stream.writeln(hilite("skipped: %s" % reason, BROWN))
コード例 #34
0
 def addSuccess(self, test):
     _TestResult.addSuccess(self, test)
     self.printStatus('TEST-PASS', test)
コード例 #35
0
 def addError(self, test, err):
     TestResult.addError(self, test, err)
     self.issue()
コード例 #36
0
 def addFailure(self, test, err):
     _TestResult.addFailure(self, test, err)
     self.printFail(test, err)
     self.stream.writeln("FAIL: {0}".format(self.getDescription(test)))
     self.stream.writeln(self.failures[-1][1])
コード例 #37
0
ファイル: testrunner.py プロジェクト: blep/weightless-core
 def startTest(self, test):
     UnitTestResult.startTest(self, test)
     if self.showAll:
         self._errWrite(str(test))
         self._errWrite(' ... ')
コード例 #38
0
 def addExpectedFailure(self, test, err):
     _TestResult.addExpectedFailure(self, test, err)
     self.printStatus('TEST-KNOWN-FAIL', test)
コード例 #39
0
ファイル: runner.py プロジェクト: zhxfei/psutil
 def addError(self, test, err):
     TestResult.addError(self, test, err)
     self.stream.writeln(hilite("ERROR", RED, bold=True))
コード例 #40
0
 def addSuccess(self, test):
     TestResult.addSuccess(self, test)
コード例 #41
0
 def addUnexpectedSuccess(self, test):
     _TestResult.addUnexpectedSuccess(self, test)
     self.printStatus('TEST-UNEXPECTED-PASS', test)
コード例 #42
0
    def addSuccess(self, test, *k):
        TestResult.addSuccess(self, test)

        self.output.write("ok\n")
コード例 #43
0
 def addSuccess(self, test):
     TestResult.addSuccess(self, test)
     self._color_print("OK", GREEN)
コード例 #44
0
ファイル: runner.py プロジェクト: zhxfei/psutil
 def addFailure(self, test, err):
     TestResult.addFailure(self, test, err)
     self.stream.writeln(hilite("FAIL", RED))
コード例 #45
0
 def addSkip(self, test, reason):
     _TestResult.addSkip(self, test, reason)
     self.printStatus('TEST-SKIP', test)
コード例 #46
0
def run_test_case_tests(test_case_class):
    test_suite = defaultTestLoader.loadTestsFromTestCase(test_case_class)
    test_result = TestResult()
    test_suite.run(test_result)
    return test_result
コード例 #47
0
 def addSkip(self, test, detail):
     if hasattr(TestResult, 'addSkip'):
         TestResult.addSkip(self, test, detail)
     else:
         self.skips.append((test, detail))
     self.addAResult(test, SKIPPED, 'SKIPPED', detail)
コード例 #48
0
 def addError(self, test, err):
     _TestResult.addError(self, test, err)
     self.printFail(test, err)
     self.stream.writeln("ERROR: {0}".format(self.getDescription(test)))
     self.stream.writeln(self.errors[-1][1])
コード例 #49
0
ファイル: runner.py プロジェクト: zhxfei/psutil
 def addSuccess(self, test):
     TestResult.addSuccess(self, test)
     self.stream.writeln(hilite("OK", GREEN))
コード例 #50
0
 def addError(self, test, err):
     TestResult.addError(self, test, err)
     self._color_print("ERROR", RED, bold=True)
コード例 #51
0
def run_module_tests(module):
    test_suite = defaultTestLoader.loadTestsFromModule(module)
    test_result = TestResult()
    test_suite.run(test_result)
    return test_result
コード例 #52
0
ファイル: testrunner.py プロジェクト: blep/weightless-core
 def addSuccess(self, test):
     UnitTestResult.addSuccess(self, test)
     if self.showAll:
         self._errWrite('ok\n')
     elif self.dots:
         self._errWrite('.')
コード例 #53
0
 def _fail_into_result(self, result: unittest.TestResult, msg):
     """Include error with the traceback into `TestResult`"""
     try:
         raise RuntimeError(msg)
     except RuntimeError:
         result.addFailure(self, sys.exc_info())
コード例 #54
0
ファイル: testrunner.py プロジェクト: blep/weightless-core
 def addFailure(self, test, err):
     UnitTestResult.addFailure(self, test, err)
     if self.showAll:
         self._errWrite('FAIL\n')
     elif self.dots:
         self._errWrite('F')
コード例 #55
0
ファイル: testrunner.py プロジェクト: blep/weightless-core
 def __init__(self, stream=stdout, errStream=stderr, verbosity=1):
     UnitTestResult.__init__(self)
     self.showAll = verbosity > 1
     self.dots = verbosity == 1
     self._errStream = errStream
     self._stream = stream
コード例 #56
0
ファイル: testrunner.py プロジェクト: blep/weightless-core
 def addError(self, test, err):
     UnitTestResult.addError(self, test, err)
     if self.showAll:
         self._errWrite('ERROR\n')
     elif self.dots:
         self._errWrite('E')
コード例 #57
0
 def addSuccess(self, test):
     TestResult.addSuccess(self, test)
     self.addAResult(test, SUCCESS, 'SUCCESS')
コード例 #58
0
 def startTest(self, test):
     TestResult.startTest(self, test)
     self.step.setProgress('tests', self.testsRun)
コード例 #59
0
ファイル: unittestpy.py プロジェクト: oikmar/fantasm
    def __init__(self, stream=sys.stdout):
        TestResult.__init__(self)

        self.output = stream

        self.createMessages()
コード例 #60
0
            "EXTENSION": {
                "dir0": {".nest"}
            },
            "DIRECTORY": {
                "dir1": {"dir0"},
                "dir2": {"dir1"},
                "dir3": {"dir2"},
                "dir4": {"dir3"},
                "dir5": {"dir4"}
            }
        }
        generate_files(self.testPath, "nestFile", extension="nest")

    def test_categorize_nested(self):
        categorize(self.testPath, self.testPath, config_dict=self.config)
        path = os.path.join(self.testPath, *["dir"+str(i) for i in range(5, -1, -1)])
        self.assertTrue(os.path.exists(path))
        self.assertTrue(os.path.isdir(path))

    def tearDown(self):
        shutil.rmtree(self.testPath)


if __name__ == "__main__":
    suite = TestSuite()
    result =TestResult()
    suite.addTest(makeSuite(UtilityFunctionTest))
    suite.addTest(makeSuite(CatergorizeSingleFileCase))
    suite.addTest(makeSuite(CategorizeMultipleFileCase))
    suite.addTest(makeSuite(CategorizeNestedDirectoryCase))
    print(TextTestRunner().run(suite))