コード例 #1
0
 def test_datetime(self):
     res = datetime.datetime(day=1,
                             month=1,
                             year=2011,
                             hour=1,
                             minute=1,
                             second=1)
     self.assertEquals(json.dumps(res), '"2011-01-01T01:01:01.000000Z"')
コード例 #2
0
ファイル: tests.py プロジェクト: anandology/opbeat_python
 def test_bytes(self):
     if six.PY2:
         res = bytes('foobar')
     else:
         res = bytes('foobar', encoding='ascii')
     self.assertEqual(json.dumps(res), '"foobar"')
コード例 #3
0
ファイル: tests.py プロジェクト: anandology/opbeat_python
 def test_frozenset(self):
     res = frozenset(['foo', 'bar'])
     self.assertIn(json.dumps(res), ('["foo", "bar"]', '["bar", "foo"]'))
コード例 #4
0
ファイル: tests.py プロジェクト: anandology/opbeat_python
 def test_datetime(self):
     res = datetime.datetime(day=1, month=1, year=2011, hour=1, minute=1, second=1)
     self.assertEquals(json.dumps(res), '"2011-01-01T01:01:01.000000Z"')
コード例 #5
0
ファイル: tests.py プロジェクト: anandology/opbeat_python
 def test_uuid(self):
     res = uuid.uuid4()
     self.assertEquals(json.dumps(res), '"%s"' % res.hex)
コード例 #6
0
ファイル: tests.py プロジェクト: rupeshparab/techscan
 def test_bytes(self):
     if six.PY2:
         res = bytes('foobar')
     else:
         res = bytes('foobar', encoding='ascii')
     self.assertEqual(json.dumps(res), '"foobar"')
コード例 #7
0
ファイル: tests.py プロジェクト: rupeshparab/techscan
 def test_frozenset(self):
     res = frozenset(['foo', 'bar'])
     self.assertIn(json.dumps(res), ('["foo", "bar"]', '["bar", "foo"]'))
コード例 #8
0
ファイル: tests.py プロジェクト: rupeshparab/techscan
 def test_uuid(self):
     res = uuid.uuid4()
     self.assertEquals(json.dumps(res), '"%s"' % res.hex)
コード例 #9
0
ファイル: base.py プロジェクト: fmartingr/opbeat_python
 def encode(self, data):
     """
     Serializes ``data`` into a raw string.
     """
     return json.dumps(data).encode('zlib')
コード例 #10
0
ファイル: tests.py プロジェクト: rSieben/opbeat_python
 def test_bytes(self):
     if six.PY2:
         res = bytes("foobar")
     else:
         res = bytes("foobar", encoding="ascii")
     self.assertEqual(json.dumps(res), '"foobar"')
コード例 #11
0
ファイル: tests.py プロジェクト: rSieben/opbeat_python
 def test_set(self):
     res = set(["foo", "bar"])
     self.assertIn(json.dumps(res), ('["foo", "bar"]', '["bar", "foo"]'))
コード例 #12
0
 def encode(self, data):
     """
     Serializes ``data`` into a raw string.
     """
     return json.dumps(data).encode('zlib')
コード例 #13
0
ファイル: base.py プロジェクト: anandology/opbeat_python
 def encode(self, data):
     """
     Serializes ``data`` into a raw string.
     """
     # return json.dumps(data).encode('zlib')
     return zlib.compress(json.dumps(data).encode('utf8'))
コード例 #14
0
 def test_frozenset(self):
     res = frozenset(['foo', 'bar'])
     self.assertEquals(json.dumps(res), '["foo", "bar"]')
コード例 #15
0
 def encode(self, data):
     """
     Serializes ``data`` into a raw string.
     """
     return zlib.compress(json.dumps(data).encode('utf8'))