Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

test_api_h.py 921 B

12345678910111213141516171819202122232425262728293031323334
  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()