diff --git a/tests/test_tokenize.py b/tests/test_tokenize.py index 0916661..f63258c 100644 --- a/tests/test_tokenize.py +++ b/tests/test_tokenize.py @@ -18,6 +18,35 @@ whitespace = " \n\t" +# Draws a random symbol location +@composite +def draw_symbol_location(draw): + line = draw(integers()) + column = draw(integers()) + filename = draw(text()) + return tokenize.SymbolLocation(line, column, filename) + + +# Test location getters +@given(integers(), integers(), text()) +def test_tokenize_location_getters(line, column, filename): + test = tokenize.SymbolLocation(line, column, filename) + assert test.line == line + assert test.column == column + assert test.file == filename + + +# Test location equals +@given(draw_symbol_location(), draw_symbol_location()) +def test_tokenize_location_equality(location1, location2): + equals = ( + location1.line == location2.line + and location1.column == location2.column + and location1.file == location2.file + ) + assert (location1 == location2) == equals + + # Draws a tokenizer non-whitespace symbol @composite def draw_symbol_nonwhitespace(draw):