MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_difference

Method test_difference

test/base/test_utils.py:1963–1988  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1961 assert_raises(TypeError, should_raise)
1962
1963 def test_difference(self):
1964 _, _, twin1, twin2, _, _ = self._create_sets()
1965
1966 # basic set math
1967 set1 = util.IdentitySet([1, 2, 3])
1968 set2 = util.IdentitySet([2, 3, 4])
1969 eq_(set1.difference(set2), util.IdentitySet([1]))
1970 eq_(set2.difference(set1), util.IdentitySet([4]))
1971
1972 # empty sets
1973 empty = util.IdentitySet([])
1974 eq_(empty.difference(empty), empty)
1975
1976 # the same sets
1977 eq_(twin1.difference(twin2), empty)
1978 eq_(twin2.difference(twin1), empty)
1979
1980 # totally different sets
1981 unique1 = util.IdentitySet([1])
1982 unique2 = util.IdentitySet([2])
1983 eq_(unique1.difference(unique2), util.IdentitySet([1]))
1984 eq_(unique2.difference(unique1), util.IdentitySet([2]))
1985
1986 # not an IdentitySet
1987 not_an_identity_set = object()
1988 assert_raises(TypeError, unique1.difference, not_an_identity_set)
1989
1990 def test_dunder_sub(self):
1991 _, _, twin1, twin2, _, _ = self._create_sets()

Callers

nothing calls this directly

Calls 4

_create_setsMethod · 0.95
differenceMethod · 0.95
eq_Function · 0.90
assert_raisesFunction · 0.90

Tested by

no test coverage detected