示例#1
0
	def load( commit, target, test ):
		""" Load test result

			raises:
				IOError: When the results files is removed while reading.

			returns:
				TestResult instance
		"""
		commit = git.describe( commit )
		fpath = os.path.join(
			config.STORAGE_DIR( test, commit=commit ),
			'result.json'
		)

		try:
			with open( fpath ) as results:
				data = json.load( results )

				result = TestResult.unserialize( test, data )
				result.test = test
		except IOError as e:
			# if the file did not exist, advice the user to run the test first
			if not os.path.exists( fpath ):
				raise ValueError( str( e ))
			else:
				raise

		logger.debug( "Loaded testresult: %s (commit: %s)" % ( str( result ), commit ))

		return result
示例#2
0
    def load(commit, target, test):
        """ Load test result

			raises:
				IOError: When the results files is removed while reading.

			returns:
				TestResult instance
		"""
        commit = git.describe(commit)
        fpath = os.path.join(config.STORAGE_DIR(test, commit=commit),
                             'result.json')

        try:
            with open(fpath) as results:
                data = json.load(results)

                result = TestResult.unserialize(test, data)
                result.test = test
        except IOError as e:
            # if the file did not exist, advice the user to run the test first
            if not os.path.exists(fpath):
                raise ValueError(str(e))
            else:
                raise

        logger.debug("Loaded testresult: %s (commit: %s)" %
                     (str(result), commit))

        return result
示例#3
0
class TestResultTestCase( unittest.TestCase ):
	"""Testcase for testing TestResults
	"""
	def setUp( self ):
		self.testresult = TestResult( TEST_MOCK, START_TIME, STOP_TIME,
									TARGET, commit=COMMIT )

	def test_serialize( self ):
		serialized = self.testresult.serialize()

		self.assertEqual( TEST_MOCK.name, serialized[ 'name' ] )
		self.assertEqual( START_TIME.isoformat( " " ), serialized[ 'started' ] )
		self.assertEqual( STOP_TIME.isoformat( " " ), serialized[ 'completed' ] )
		self.assertEqual( TARGET, serialized[ 'target' ] )
		self.assertEqual( COMMIT, serialized[ 'commit' ] )
示例#4
0
class TestResultTestCase(unittest.TestCase):
    """Testcase for testing TestResults
	"""
    def setUp(self):
        self.testresult = TestResult(TEST_MOCK,
                                     START_TIME,
                                     STOP_TIME,
                                     TARGET,
                                     commit=COMMIT)

    def test_serialize(self):
        serialized = self.testresult.serialize()

        self.assertEqual(TEST_MOCK.name, serialized['name'])
        self.assertEqual(START_TIME.isoformat(" "), serialized['started'])
        self.assertEqual(STOP_TIME.isoformat(" "), serialized['completed'])
        self.assertEqual(TARGET, serialized['target'])
        self.assertEqual(COMMIT, serialized['commit'])
示例#5
0
	def setUp( self ):
		self.testresult = TestResult( TEST_MOCK, START_TIME, STOP_TIME,
									TARGET, commit=COMMIT )
示例#6
0
 def setUp(self):
     self.testresult = TestResult(TEST_MOCK,
                                  START_TIME,
                                  STOP_TIME,
                                  TARGET,
                                  commit=COMMIT)