Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
test_exceptions.py35 linesDownload Raw Back to tests
1import itertools2 3import pytest4 5from referencing import Resource, exceptions6 7 8def pairs(choices):9    return itertools.combinations(choices, 2)10 11 12TRUE = Resource.opaque(True)13 14 15thunks = (16    lambda: exceptions.CannotDetermineSpecification(TRUE),17    lambda: exceptions.NoSuchResource("urn:example:foo"),18    lambda: exceptions.NoInternalID(TRUE),19    lambda: exceptions.InvalidAnchor(resource=TRUE, anchor="foo", ref="a#b"),20    lambda: exceptions.NoSuchAnchor(resource=TRUE, anchor="foo", ref="a#b"),21    lambda: exceptions.PointerToNowhere(resource=TRUE, ref="urn:example:foo"),22    lambda: exceptions.Unresolvable("urn:example:foo"),23    lambda: exceptions.Unretrievable("urn:example:foo"),24)25 26 27@pytest.mark.parametrize("one, two", pairs(each() for each in thunks))28def test_eq_incompatible_types(one, two):29    assert one != two30 31 32@pytest.mark.parametrize("thunk", thunks)33def test_hash(thunk):34    assert thunk() in {thunk()}35 
codekingpro/portable-devtools · Team Ai