init_test.py 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. import pytest
  2. from freesurfer_volume_reader import parse_version_string, remove_group_names_from_regex
  3. @pytest.mark.parametrize(('version_string', 'expected_tuple'), [
  4. ('0.24.2', (0, 24, 2)),
  5. ('0.21.0', (0, 21, 0)),
  6. ('0.2.2.dev28+g526f05c.d20190504', (0, 2, 2, 'dev28+g526f05c', 'd20190504')),
  7. ])
  8. def test_parse_version_string(version_string, expected_tuple):
  9. assert expected_tuple == parse_version_string(version_string)
  10. def test_parse_version_string_comparison():
  11. assert parse_version_string('0.24.2') == (0, 24, 2)
  12. assert parse_version_string('0.24.2') < (0, 25)
  13. assert parse_version_string('0.24.2') < (0, 24, 3)
  14. assert parse_version_string('0.24.2') <= (0, 24, 2)
  15. assert parse_version_string('0.24.2') >= (0, 24, 2)
  16. assert parse_version_string('0.24.2') > (0, 24, 1)
  17. assert parse_version_string('0.24.2') > (0, 24)
  18. assert parse_version_string('0.2.2.dev28+g526f05c.d20190504') > (0, 2, 2)
  19. assert parse_version_string('0.2.2.dev28+g526f05c.d20190504') < (0, 2, 3)
  20. @pytest.mark.parametrize(('source_pattern', 'expected_pattern'), [
  21. (r'^(?P<h>[lr])h\.hippoSfVolumes', r'^([lr])h\.hippoSfVolumes'),
  22. (r'(?P<a>a(?P<b>b))', r'(a(b))'),
  23. ])
  24. def test_remove_group_names_from_regex(source_pattern, expected_pattern):
  25. assert expected_pattern == remove_group_names_from_regex(regex_pattern=source_pattern)