MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_difference

Method test_difference

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

Source from the content-addressed store, hash-verified

1866 assert_raises(TypeError, should_raise)
1867
1868 def test_difference(self):
1869 _, _, twin1, twin2, _, _ = self._create_sets()
1870
1871 # basic set math
1872 set1 = util.IdentitySet([1, 2, 3])
1873 set2 = util.IdentitySet([2, 3, 4])
1874 eq_(set1.difference(set2), util.IdentitySet([1]))
1875 eq_(set2.difference(set1), util.IdentitySet([4]))
1876
1877 # empty sets
1878 empty = util.IdentitySet([])
1879 eq_(empty.difference(empty), empty)
1880
1881 # the same sets
1882 eq_(twin1.difference(twin2), empty)
1883 eq_(twin2.difference(twin1), empty)
1884
1885 # totally different sets
1886 unique1 = util.IdentitySet([1])
1887 unique2 = util.IdentitySet([2])
1888 eq_(unique1.difference(unique2), util.IdentitySet([1]))
1889 eq_(unique2.difference(unique1), util.IdentitySet([2]))
1890
1891 # not an IdentitySet
1892 not_an_identity_set = object()
1893 assert_raises(TypeError, unique1.difference, not_an_identity_set)
1894
1895 def test_dunder_sub(self):
1896 _, _, 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