コード例 #1
0
def pytest_unconfigure(config):
    global data
    global reporting
    # Report Build Information (Optional)
    # buildcase = {
    # 'name': '1.0.0', #get_build_number()
    # 'result': 'pass', # Must be 'pass' , 'fail', or 'unknown'
    # 'suite':  '[build]' # Do not change. Indicates this is build information and not a test
    # As with tests you can also add a desc (description), reason, and files!
    # }
    # data['results']['cases'].append(buildcase)
    # log.info(config)
    # log.info(reporting)
    # print(reporting)
    if reporting == 'yes':
        print('-----Tesults output-----')
        if len(data['results']['cases']) > 0:
            print('data: ' + str(data))
            ret = tesults.results(data)
            print('success: ' + str(ret['success']))
            print('message: ' + str(ret['message']))
            print('warnings: ' + str(ret['warnings']))
            print('errors: ' + str(ret['errors']))
        else:
            print('No test results.')
    else:
        print('-----No Reporting-----')
コード例 #2
0
def pytest_unconfigure(config):
    global data
    print('-----Tesults output-----')
    if len(data['results']['cases']) > 0:
        print('data: ' + str(data))
        ret = tesults.results(data)
        print('success: ' + str(ret['success']))
        print('message: ' + str(ret['message']))
        print('warnings: ' + str(ret['warnings']))
        print('errors: ' + str(ret['errors']))
    else:
        print('No test results.')
コード例 #3
0
def post_results_to_tesults():
    token = conf_file.target_token_default  # uses default token unless otherwise specified
    data = {'target': token, 'results': {'cases': cases}}
    print('-----Tesults output-----')
    if len(data['results']['cases']) > 0:
        print(data)
        print('Uploading results to Tesults...')
        ret = tesults.results(data)
        print('success: ' + str(ret['success']))
        print('message: ' + str(ret['message']))
        print('warnings: ' + str(ret['warnings']))
        print('errors: ' + str(ret['errors']))
    else:
        print('No test results.')
コード例 #4
0
def main():
    data = {
        'target': 'token',
        'results': {
            'cases': [{
                'name':
                'Test 1',
                'desc':
                'Test 1 desc',
                'suite':
                'Suite A',
                'result':
                'pass',
                'files': [
                    '/Users/admin/Desktop/img1.png',
                    '/Users/admin/Desktop/img2.png'
                ]
            }, {
                'name':
                'Test 2',
                'desc':
                'Test 2 desc',
                'suite':
                'Suite A',
                'result':
                'pass',
                'files': [
                    '/Users/admin/Desktop/img3.png',
                    '/Users/admin/Desktop/img4.png'
                ]
            }, {
                'name': 'Test 3',
                'desc': 'Test 3 desc',
                'suite': 'Suite A',
                'result': 'pass',
                'files': ['/Users/admin/Desktop/img4.png']
            }]
        }
    }

    response = tesults.results(data)
    print('success: ' + str(response.get('success')))
    print('message: ' + response.get('message'))
    print('warnings: ' + str(len(response.get('warnings'))))
    print('errors: ' + str(len(response.get('errors'))))
コード例 #5
0
    def upload_results(self):
        if not self.testcases:
            # Report no test cases
            return

        build_case = {"name": self.build_name, "result": self.build_result, "suite": "[build]"}
        if self.build_desc:
            build_case["desc"] = self.build_desc
        if self.build_reason:
            build_case["reason"] = self.build_reason
        build_files = self.files_for_test(build_case["suite"], self.build_name)
        if build_files:
            build_case["files"] = build_files

        self.testcases.append(build_case)

        data = {"target": self.build_token, "results": {"cases": self.testcases}}
        return tesults.results(data)
コード例 #6
0
    def close(self):
        if (self.disabled == True):
            return
        if (self.buildName is not None):
            buildcase = {
                'name': self.buildName,
                'suite': '[build]',
                'result': 'unknown'
            }
            if (self.buildResult is not None):
                if (self.buildResult.lower() == 'pass'):
                    buildcase['result'] = 'pass'
                if (self.buildResult.lower() == 'fail'):
                    buildcase['result'] = 'fail'
            if (self.buildDesc is not None):
                buildcase['desc'] = self.buildDesc
            if (self.buildReason is not None):
                buildcase['reason'] = self.buildReason
            if (self.filespath is not None):
                files = self.filesForTest(buildcase['suite'],
                                          buildcase['name'])
                if (files is not None):
                    if (len(files) > 0):
                        buildcase['files'] = files
            self.data['results']['cases'].append(buildcase)

        for c in self.data['results']['cases']:
            c.pop('robot-id', None)

        self.data['target'] = self.target
        print('-----Tesults results upload...-----')
        if len(self.data['results']['cases']) > 0:
            #print('data: ' + str(self.data))
            ret = tesults.results(self.data)
            print('success: ' + str(ret['success']))
            print('message: ' + str(ret['message']))
            print('warnings: ' + str(ret['warnings']))
            print('errors: ' + str(ret['errors']))
        else:
            print('No test results.')
コード例 #7
0
ファイル: pytest_tesults.py プロジェクト: tesults/pytest
def pytest_unconfigure(config):
    global disabled
    if (disabled == True):
        return
    global data
    global buildcase
    if (buildcase):
        buildfiles = filesForTest(buildcase['suite'], buildcase['name'])
        if (buildfiles):
            if len(buildfiles) > 0:
                buildcase['files'] = buildfiles
        data['results']['cases'].append(buildcase)

    print('Tesults results uploading...')
    if len(data['results']['cases']) > 0:
        #print ('data: ' + str(data))
        ret = tesults.results(data)
        print('success: ' + str(ret['success']))
        print('message: ' + str(ret['message']))
        print('warnings: ' + str(ret['warnings']))
        print('errors: ' + str(ret['errors']))
    else:
        print('No test results.')