Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_stdlib.py 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  2. # For details: https://github.com/PyCQA/pylint/blob/master/COPYING
  3. import contextlib
  4. import io
  5. import os
  6. import sys
  7. import pytest
  8. import six
  9. import pylint.lint
  10. def is_module(filename):
  11. return filename.endswith(".py")
  12. def is_package(filename, location):
  13. return os.path.exists(os.path.join(location, filename, '__init__.py'))
  14. @contextlib.contextmanager
  15. def _patch_stdout(out):
  16. sys.stdout = out
  17. try:
  18. yield
  19. finally:
  20. sys.stdout = sys.__stdout__
  21. LIB_DIRS = [
  22. os.path.dirname(os.__file__),
  23. ]
  24. MODULES_TO_CHECK = [(location, module) for location in LIB_DIRS for module in os.listdir(location)
  25. if is_module(module) or is_package(module, location)]
  26. MODULES_NAMES = [m[1] for m in MODULES_TO_CHECK]
  27. @pytest.mark.acceptance
  28. @pytest.mark.parametrize(("test_module_location", "test_module_name"),
  29. MODULES_TO_CHECK, ids=MODULES_NAMES)
  30. def test_libmodule(test_module_location, test_module_name):
  31. os.chdir(test_module_location)
  32. with _patch_stdout(six.StringIO()):
  33. try:
  34. pylint.lint.Run([test_module_name, '--enable=all'])
  35. except SystemExit as ex:
  36. assert ex.code != 32
  37. return
  38. assert False, "shouldn't get there"