def test_equality(self): ''' Test basic equality comparison for `util.struct.Sentinel`. ''' SAMPLE = struct.Sentinel('SAMPLE') assert SAMPLE.name == "SAMPLE" SAMPLE2 = struct.Sentinel('SAMPLE') assert SAMPLE == SAMPLE2
''' __version__ = 'v3' # stdlib import abc import operator # canteen utils from canteen.util import struct as datastructures ## Globals / Constants # Filter components _TARGET_KEY = datastructures.Sentinel('KEY') PROPERTY = datastructures.Sentinel('PROPERTY') KEY_KIND = datastructures.Sentinel('KEY_KIND') KEY_ANCESTOR = datastructures.Sentinel('KEY_ANCESTOR') # Sort directions ASCENDING = ASC = datastructures.Sentinel('ASCENDING') DESCENDING = DSC = datastructures.Sentinel('DESCENDING') # Query operators EQUALS = EQ = datastructures.Sentinel('EQUALS') NOT_EQUALS = NE = datastructures.Sentinel('NOT_EQUALS') LESS_THAN = LT = datastructures.Sentinel('LESS_THAN') LESS_THAN_EQUAL_TO = LE = datastructures.Sentinel('LESS_THAN_EQUAL_TO') GREATER_THAN = GT = datastructures.Sentinel('GREATER_THAN') GREATER_THAN_EQUAL_TO = GE = datastructures.Sentinel('GREATER_THAN_EQUAL_TO')
def test_not_falsy(self): ''' Test ability to set a Sentinel as truthy. ''' GOOD = struct.Sentinel('GOOD', falsy=False) assert GOOD
def test_falsy(self): ''' Test ability to set a Sentinel as falsy. ''' BAD = struct.Sentinel('BAD', falsy=True) assert not BAD
def test_repr(self): ''' Test basic string representation of a `util.struct.Sentinel`. ''' SAMPLE = struct.Sentinel('SAMPLE') assert 'SAMPLE' in str(SAMPLE)
def test_construct(self): ''' Test basic functionality of `util.struct.Sentinel`. ''' SAMPLE = struct.Sentinel('SAMPLE') assert SAMPLE.name == "SAMPLE"