mirror of
https://github.com/donnemartin/data-science-ipython-notebooks.git
synced 2024-03-22 13:30:56 +08:00
Added snippet for datetime
This commit is contained in:
parent
a5b6a3735f
commit
9d92a16ea5
5
core/date_util.py
Normal file
5
core/date_util.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
class DateUtil:
|
||||
|
||||
@classmethod
|
||||
def Foo(cls):
|
||||
pass
|
34
core/tests/test_date_util.py
Normal file
34
core/tests/test_date_util.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
from nose.tools import assert_equal
|
||||
from datetime import datetime, date, time
|
||||
|
||||
|
||||
class TestDateUtil():
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
"""This method is run once for each class before any tests are run"""
|
||||
|
||||
@classmethod
|
||||
def teardown_class(cls):
|
||||
"""This method is run once for each class _after_ all tests are run"""
|
||||
|
||||
def setUp(self):
|
||||
"""This method is run once before _each_ test method is executed"""
|
||||
|
||||
def teardown(self):
|
||||
"""This method is run once after _each_ test method is executed"""
|
||||
|
||||
year = 2015
|
||||
month = 1
|
||||
day = 20
|
||||
hour = 7
|
||||
minute = 28
|
||||
second = 15
|
||||
|
||||
def test_datetime(self):
|
||||
dt = datetime(self.year, self.month, self.day,
|
||||
self.hour, self.minute, self.second)
|
||||
assert_equal(dt.day, self.day)
|
||||
assert_equal(dt.minute, self.minute)
|
||||
assert_equal(dt.date(), date(self.year, self.month, self.day))
|
||||
assert_equal(dt.time(), time(self.hour, self.minute, self.second))
|
Loading…
Reference in New Issue
Block a user