mirror of
https://github.com/donnemartin/data-science-ipython-notebooks.git
synced 2024-03-22 13:30:56 +08:00
Added snippet that tests for whether an object is of a particular instance
This commit is contained in:
parent
3c272027e1
commit
67b939f1bc
30
tests/test_util.py
Normal file
30
tests/test_util.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
from nose.tools import assert_equal
|
||||
|
||||
|
||||
class TestUtil():
|
||||
|
||||
@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"""
|
||||
|
||||
def test_isinstance(self):
|
||||
assert_equal(isinstance(7, (int)), True)
|
||||
assert_equal(isinstance(7.5, (int, float)), True)
|
||||
assert_equal(isinstance('foo', (int, float, str)), True)
|
||||
|
||||
def main():
|
||||
test = TestUtil()
|
||||
test.test_isinstance()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue
Block a user