-
-
Notifications
You must be signed in to change notification settings - Fork 424
Expand file tree
/
Copy pathtest_module.py
More file actions
34 lines (18 loc) · 831 Bytes
/
test_module.py
File metadata and controls
34 lines (18 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding: utf-8 -*-
import pendulum
from .. import AbstractTestCase
from pendulum.formatting import register_formatter, Formatter
class ModuleTestCase(AbstractTestCase):
def test_register_formatter(self):
register_formatter('test', TestFormatter())
self.assertEqual('foo', pendulum.now().format('', formatter='test'))
def test_register_formatter_existing_name(self):
self.assertRaises(ValueError, register_formatter, 'classic', TestFormatter())
def test_register_formatter_not_formatter_instance(self):
self.assertRaises(ValueError, register_formatter, 'test', FooFormatter())
class TestFormatter(Formatter):
def format(self, dt, fmt, locale=None):
return 'foo'
class FooFormatter(object):
def format(self, dt, fmt, locale=None):
return 'foo'