From e94bebfb61125e19b27f48ff3fa04b9eebe7c78c Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Sat, 24 Jan 2015 06:54:21 -0500 Subject: [PATCH] Added snippet to test for references, is versus == --- core/tests/test_util.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/tests/test_util.py b/core/tests/test_util.py index c00d5f6..2f0e947 100644 --- a/core/tests/test_util.py +++ b/core/tests/test_util.py @@ -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) \ No newline at end of file + 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) +