Added snippet to test for references, is versus ==

This commit is contained in:
Donne Martin 2015-01-24 06:54:21 -05:00
parent bd7547d3c8
commit e94bebfb61

View File

@ -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)