Better assertEqual() for os.stat(myfile).st_mode
问题 I have a code that checks the st_mode of a file: self.assertEqual(16877, os.stat(my_directory).st_mode) Only old school unix experts are able to decipher the integer value 16877 fluently. Is there more readable way to check for exactly this value? 回答1: If I may extend the question a bit and understand it as “Is there more readable way to check file modes?”, then I'll suggest adding a custom assertion. The target: self.assertFileMode(my_directory, user="rwx", group="rx", others="rx") How to do