test_all_fixers.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. """Tests that run all fixer modules over an input stream.
  2. This has been broken out into its own test module because of its
  3. running time.
  4. """
  5. # Author: Collin Winter
  6. # Python imports
  7. import os.path
  8. import sys
  9. import test.support
  10. import unittest
  11. # Local imports
  12. from . import support
  13. @test.support.requires_resource('cpu')
  14. class Test_all(support.TestCase):
  15. def setUp(self):
  16. self.refactor = support.get_refactorer()
  17. def refactor_file(self, filepath):
  18. if test.support.verbose:
  19. print(f"Refactor file: {filepath}")
  20. if os.path.basename(filepath) == 'infinite_recursion.py':
  21. # bpo-46542: Processing infinite_recursion.py can crash Python
  22. # if Python is built in debug mode: lower the recursion limit
  23. # to prevent a crash.
  24. with test.support.infinite_recursion(150):
  25. self.refactor.refactor_file(filepath)
  26. else:
  27. self.refactor.refactor_file(filepath)
  28. def test_all_project_files(self):
  29. for filepath in support.all_project_files():
  30. with self.subTest(filepath=filepath):
  31. self.refactor_file(filepath)
  32. if __name__ == '__main__':
  33. unittest.main()