選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

35 行
921 B

  1. import os
  2. import re
  3. import helpers
  4. import pqclean
  5. def test_preprocessor():
  6. for scheme in pqclean.Scheme.all_schemes():
  7. for implementation in scheme.implementations:
  8. if helpers.permit_test('preprocessor', implementation):
  9. yield check_preprocessor, implementation
  10. def check_preprocessor(implementation: pqclean.Implementation):
  11. apipath = os.path.join(implementation.path(), 'api.h')
  12. errors = []
  13. p = re.compile(r'^\s*#include\s*"')
  14. with open(apipath) as f:
  15. for i, line in enumerate(f):
  16. if p.match(line):
  17. errors.append("\n at {}:{}".format(apipath, i+1))
  18. if errors:
  19. raise AssertionError(
  20. "Prohibited external include in api.h" + "".join(errors)
  21. )
  22. if __name__ == "__main__":
  23. try:
  24. import nose2
  25. nose2.main()
  26. except ImportError:
  27. import nose
  28. nose.runmodule()