diff options
author | Zachary Ware <zachary.ware@gmail.com> | 2014-06-19 14:46:37 (GMT) |
---|---|---|
committer | Zachary Ware <zachary.ware@gmail.com> | 2014-06-19 14:46:37 (GMT) |
commit | 63f277b6944d583596675970666bbf4152b83349 (patch) | |
tree | 56892f523e2da97d4bcec0593c919136516b1376 /Lib/test/test_os.py | |
parent | 6ef1202eb9de1a402a3fe14df05d90ae93e78d3e (diff) | |
download | cpython-63f277b6944d583596675970666bbf4152b83349.zip cpython-63f277b6944d583596675970666bbf4152b83349.tar.gz cpython-63f277b6944d583596675970666bbf4152b83349.tar.bz2 |
Issue #21741: Add st_file_attributes to os.stat_result on Windows.
Patch by Ben Hoyt.
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r-- | Lib/test/test_os.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 7d5ee69..f559841 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -530,6 +530,28 @@ class StatAttributeTests(unittest.TestCase): os.stat(r) self.assertEqual(ctx.exception.errno, errno.EBADF) + def check_file_attributes(self, result): + self.assertTrue(hasattr(result, 'st_file_attributes')) + self.assertTrue(isinstance(result.st_file_attributes, int)) + self.assertTrue(0 <= result.st_file_attributes <= 0xFFFFFFFF) + + @unittest.skipUnless(sys.platform == "win32", + "st_file_attributes is Win32 specific") + def test_file_attributes(self): + # test file st_file_attributes (FILE_ATTRIBUTE_DIRECTORY not set) + result = os.stat(self.fname) + self.check_file_attributes(result) + self.assertEqual( + result.st_file_attributes & stat.FILE_ATTRIBUTE_DIRECTORY, + 0) + + # test directory st_file_attributes (FILE_ATTRIBUTE_DIRECTORY set) + result = os.stat(support.TESTFN) + self.check_file_attributes(result) + self.assertEqual( + result.st_file_attributes & stat.FILE_ATTRIBUTE_DIRECTORY, + stat.FILE_ATTRIBUTE_DIRECTORY) + from test import mapping_tests class EnvironTests(mapping_tests.BasicTestMappingProtocol): |