Pokemon-Terminal/test_filters.py
Samuel Henrique d96d4a8bb5 More testing
- Adds new tests of the new command engine
- Regions and pokemon types and names are now case insensitive
-  Roll back some of the removed tests.
2017-07-06 12:32:27 -03:00

29 lines
960 B
Python

from filters import Filter
import pytest
def test_basic_loading():
assert len(Filter.POKEMON_LIST) >= 493
assert len(Filter.filtered_list) == len(Filter.POKEMON_LIST)
def test_filters_infrastructure():
inst = Filter(None, None)
with pytest.raises(NotImplementedError):
inst.matches(None, None)
for fltr in Filter.FILTERS:
fltr = fltr(None, None)
filtered = [pkmn for pkmn in Filter.POKEMON_LIST
if fltr.matches(pkmn, fltr.EXAMPLE_VAL)]
assert len(filtered) < len(Filter.POKEMON_LIST)
if __name__ == '__main__':
# Test runner: Runs all functions whose name begins with `test_`
# locals() changes when trying to do this without the list comprehension!!!
name_funcs = [(n, f) for n, f in locals().items() if n.startswith('test_')]
for name, func in name_funcs:
if callable(func):
func()
else:
print(name + ' is not callable()!')