def test_equals(self): # Test __eq and = both qlObjs = QueryableListObjs(self.dataObjs) found = qlObjs.filter(a='six') assert len( found) == 1, 'Expected to find one item in query(=), found %d' % ( len(found), ) assert found[0].a == 'six' and found[ 0].c == 'eleven', 'Found wrong item from equals query' found = qlObjs.filter(a__eq='six') assert len( found ) == 1, 'Expected to find one item in query(__eq), found %d' % ( len(found), ) assert found[0].a == 'six' and found[ 0].c == 'eleven', 'Found wrong item from equals query' found = QueryableListObjs(self.dataObjs).filter(a__eq='one') assert len( found) == 2, 'Expected to find two items in query, found %d' % ( len(found), ) assert found.count( ) == 2, 'Expected count() to return 2 elements. Got: %d' % ( found.count(), )
def test_copy(self): qlObjs = QueryableListObjs(self.dataObjs) assert copy.copy( qlObjs) == qlObjs, "Expected copy to equal the original" assert id(copy.copy(qlObjs)) != id( qlObjs), 'Expected id of copy to not euqla original' assert copy.deepcopy( qlObjs) != qlObjs, "Expected deepcopy to NOT equal the original" assert copy.deepcopy(qlObjs).count() == qlObjs.count( ), 'Expected deepcopy to have same number of items' aObjs = qlObjs.filter(a='one') assert copy.copy( aObjs ) == aObjs, 'After filter, expected copy to equal filtered original' assert id(copy.copy(aObjs)) != id( aObjs ), 'After filter, expected id of copy to not equal id of filtered original' assert copy.deepcopy( aObjs ) != aObjs, 'After filter, expected deepcopy to NOT equal filtered original' assert copy.deepcopy(aObjs).count() == aObjs.count( ), 'Expected deepcopy to have same number of items'