1# Copyright 2009 Google Inc. All Rights Reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15"""A test suite that runs all tests for pyfakefs at once. 16Includes tests with external pathlib2 and scandir packages if installed.""" 17 18import sys 19import unittest 20 21from pyfakefs.tests import ( 22 dynamic_patch_test, 23 fake_stat_time_test, 24 example_test, 25 fake_filesystem_glob_test, 26 fake_filesystem_shutil_test, 27 fake_filesystem_test, 28 fake_filesystem_unittest_test, 29 fake_filesystem_vs_real_test, 30 fake_open_test, 31 fake_os_test, 32 fake_pathlib_test, 33 fake_tempfile_test, 34 patched_packages_test, 35 fake_legacy_modules_test, 36 mox3_stubout_test, 37) 38 39 40class AllTests(unittest.TestSuite): 41 """A test suite that runs all tests for pyfakefs at once.""" 42 43 def suite(self): # pylint: disable-msg=C6409 44 loader = unittest.defaultTestLoader 45 self.addTests( 46 [ 47 loader.loadTestsFromModule(fake_filesystem_test), 48 loader.loadTestsFromModule(fake_filesystem_glob_test), 49 loader.loadTestsFromModule(fake_filesystem_shutil_test), 50 loader.loadTestsFromModule(fake_os_test), 51 loader.loadTestsFromModule(fake_stat_time_test), 52 loader.loadTestsFromModule(fake_open_test), 53 loader.loadTestsFromModule(fake_tempfile_test), 54 loader.loadTestsFromModule(fake_filesystem_vs_real_test), 55 loader.loadTestsFromModule(fake_filesystem_unittest_test), 56 loader.loadTestsFromModule(example_test), 57 loader.loadTestsFromModule(mox3_stubout_test), 58 loader.loadTestsFromModule(dynamic_patch_test), 59 loader.loadTestsFromModule(fake_pathlib_test), 60 loader.loadTestsFromModule(patched_packages_test), 61 loader.loadTestsFromModule(fake_legacy_modules_test), 62 ] 63 ) 64 return self 65 66 67if __name__ == "__main__": 68 result = unittest.TextTestRunner(verbosity=2).run(AllTests().suite()) 69 sys.exit(int(not result.wasSuccessful())) 70