コード例 #1
0
 def test_measure(self):
     c = Counter(CounterTest.tid)
     c.increment()
     ms = c._measure()
     self.assertEqual(len(ms), 1)
     self.assertEqual(ms[CounterTest.tid.with_stat('count')], 1)
     self.assertEquals(c.count(), 0)
コード例 #2
0
ファイル: registry.py プロジェクト: reallistic/spectator-py
 def counter(self, name, tags=None):
     return self._new_meter(name, tags, lambda id: Counter(id), Counter,
                            self.noopCounter)
コード例 #3
0
 def test_count(self):
     """Avoid breaking the API."""
     c = Counter(self.tid, writer=MemoryWriter())
     c.increment()
     self.assertEqual(0, c.count())
コード例 #4
0
 def test_increment_negative(self):
     c = Counter(self.tid, writer=MemoryWriter())
     c.increment(-1)
     self.assertTrue(c._writer.is_empty())
コード例 #5
0
    def test_increment(self):
        c = Counter(self.tid, writer=MemoryWriter())
        self.assertTrue(c._writer.is_empty())

        c.increment()
        self.assertEqual("c:test:1", c._writer.last_line())
コード例 #6
0
 def test_increment(self):
     c = Counter(CounterTest.tid)
     self.assertEqual(c.count(), 0)
     c.increment()
     self.assertEqual(c.count(), 1)
コード例 #7
0
 def test_increment_negative(self):
     c = Counter(CounterTest.tid)
     c.increment(-1)
     self.assertEqual(c.count(), 0)
コード例 #8
0
 def test_user_statistic(self):
     c = Counter(CounterTest.tid.with_stat('totalTime'))
     c.increment()
     for id in c._measure().keys():
         self.assertEqual('totalTime', id.tags()['statistic'])
コード例 #9
0
 def counter(self, name: str, tags: Optional[dict] = None) -> Counter:
     return Counter(self._new_meter(name, tags), writer=self._writer)