test_CI_reqs.py 935 B

12345678910111213141516171819202122232425262728293031323334353637
  1. from __future__ import absolute_import, unicode_literals
  2. import os
  3. import pprint
  4. import pytest
  5. def _get_extras_reqs_from(name):
  6. try:
  7. with open(os.path.join('requirements', name)) as fh:
  8. lines = fh.readlines()
  9. except OSError:
  10. pytest.skip('requirements dir missing, not running from dist?')
  11. else:
  12. return {
  13. line.split()[1] for line in lines
  14. if line.startswith('-r extras/')
  15. }
  16. def _get_all_extras():
  17. return set(
  18. os.path.join('extras', f)
  19. for f in os.listdir('requirements/extras/')
  20. )
  21. def test_all_reqs_enabled_in_tests():
  22. ci_default = _get_extras_reqs_from('test-ci-default.txt')
  23. ci_base = _get_extras_reqs_from('test-ci-base.txt')
  24. defined = ci_default | ci_base
  25. all_extras = _get_all_extras()
  26. diff = all_extras - defined
  27. print('Missing CI reqs:\n{0}'.format(pprint.pformat(diff)))
  28. assert not diff