Example #1
0
 def setUp(self):
     self.data = AchievementData({
         'time.start': datetime.now(),
         'time.finish': datetime.now()
     })
     self.stream = StringIO()
     self.data.save(self.stream)
     self.stream.seek(0)
Example #2
0
 def finalize(self, data, result):
     if self.enabled and data['result.success']:
         coverage = self.coverage()
         coverage.load()
         report = StringIO()
         coverage.report(file=report)
         report_string = report.getvalue()
         last_line = report_string.splitlines()[-1]
         match = re.match(r'TOTAL\s+(?P<stmts>\d+)\s+(?P<exec>\d+)\s+'
                          r'(?P<cover>\d+)%', last_line)
         if match:
             statements = int(match.group('stmts'))
             executed = int(match.group('exec'))
             percent_covered = int(match.group('cover'))
             if percent_covered == 100:
                 level = int(math.log(statements, 2) - 7)
                 data.unlock(self)
Example #3
0
 def finalize(self, data, result):
     if self.enabled and data['result.success']:
         coverage = self.coverage()
         coverage.load()
         report = StringIO()
         coverage.report(file=report)
         report_string = report.getvalue()
         last_line = report_string.splitlines()[-1]
         match = re.match(
             r'TOTAL\s+(?P<stmts>\d+)\s+(?P<exec>\d+)\s+'
             r'(?P<cover>\d+)%', last_line)
         if match:
             statements = int(match.group('stmts'))
             executed = int(match.group('exec'))
             percent_covered = int(match.group('cover'))
             if percent_covered == 100:
                 level = int(math.log(statements, 2) - 7)
                 data.unlock(self)
Example #4
0
class TestAchievementData(unittest.TestCase):
    def setUp(self):
        self.data = AchievementData({'time.start': datetime.now(),
                                     'time.finish': datetime.now()})
        self.stream = StringIO()
        self.data.save(self.stream)
        self.stream.seek(0)

    def test_is_dict(self):
        self.assert_(isinstance(self.data, dict))

    def test_save_writes_data_to_stream(self):
        stream = StringIO()
        dump(self.data, stream, AchievementData.PICKLE_PROTOCOL)
        self.assertEqual(self.stream.getvalue(), stream.getvalue())

    def test_load_reads_data_from_stream(self):
        data = AchievementData.load(self.stream)
        self.assertEqual(self.data, data)
Example #5
0
class TestAchievementData(unittest.TestCase):
    def setUp(self):
        self.data = AchievementData({
            'time.start': datetime.now(),
            'time.finish': datetime.now()
        })
        self.stream = StringIO()
        self.data.save(self.stream)
        self.stream.seek(0)

    def test_is_dict(self):
        self.assert_(isinstance(self.data, dict))

    def test_save_writes_data_to_stream(self):
        stream = StringIO()
        dump(self.data, stream, AchievementData.PICKLE_PROTOCOL)
        self.assertEqual(self.stream.getvalue(), stream.getvalue())

    def test_load_reads_data_from_stream(self):
        data = AchievementData.load(self.stream)
        self.assertEqual(self.data, data)
Example #6
0
 def test_data_is_serializable(self):
     if self.plugin.enabled:
         stream = StringIO()
         self.plugin.data.save(stream)
         self.assertTrue(stream.getvalue())
Example #7
0
 def setUp(self):
     self.stream = StringIO()
Example #8
0
 def test_save_writes_data_to_stream(self):
     stream = StringIO()
     dump(self.data, stream, AchievementData.PICKLE_PROTOCOL)
     self.assertEqual(self.stream.getvalue(), stream.getvalue())
Example #9
0
 def test_data_is_serializable(self):
     if self.plugin.enabled:
         stream = StringIO()
         self.plugin.data.save(stream)
         self.assertTrue(stream.getvalue())
Example #10
0
 def test_save_writes_data_to_stream(self):
     stream = StringIO()
     dump(self.data, stream, AchievementData.PICKLE_PROTOCOL)
     self.assertEqual(self.stream.getvalue(), stream.getvalue())
Example #11
0
 def setUp(self):
     self.data = AchievementData({'time.start': datetime.now(),
                                  'time.finish': datetime.now()})
     self.stream = StringIO()
     self.data.save(self.stream)
     self.stream.seek(0)