mirror of
https://github.com/donnemartin/data-science-ipython-notebooks.git
synced 2024-03-22 13:30:56 +08:00
Added snippet to test for references, is versus ==
This commit is contained in:
parent
bd7547d3c8
commit
e94bebfb61
|
@ -1,6 +1,6 @@
|
|||
from nose.tools import assert_equal
|
||||
from nose.tools import raises
|
||||
from pydatasnippets.util import Util
|
||||
from pydatasnippets.core.util import Util
|
||||
|
||||
|
||||
class TestUtil():
|
||||
|
@ -42,4 +42,14 @@ class TestUtil():
|
|||
|
||||
def test_convert_to_list(obj):
|
||||
assert_equal(isinstance(Util.convert_to_list('foo'), list), True)
|
||||
assert_equal(isinstance(Util.convert_to_list(7), list), False)
|
||||
assert_equal(isinstance(Util.convert_to_list(7), list), False)
|
||||
|
||||
def test_references(self):
|
||||
a = [1, 2, 3]
|
||||
b = a
|
||||
c = list(a) # list always creates a new list
|
||||
assert_equal(a == b, True)
|
||||
assert_equal(a is b, True)
|
||||
assert_equal(a == c, True)
|
||||
assert_equal(a is c, False)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user