|
25 | 25 | import unittest |
26 | 26 |
|
27 | 27 | from pyfakefs import fake_filesystem, helpers |
28 | | -from pyfakefs.helpers import is_root |
| 28 | +from pyfakefs.helpers import is_root, IS_PYPY |
29 | 29 | from pyfakefs.fake_io import FakeIoModule |
30 | 30 | from pyfakefs.fake_filesystem_unittest import PatchMode |
31 | 31 | from pyfakefs.tests.test_utils import RealFsTestCase |
@@ -1057,10 +1057,19 @@ def tearDown(self): |
1057 | 1057 | self.filesystem.patch_open_code = False |
1058 | 1058 | super(FakeFilePatchedOpenCodeTest, self).tearDown() |
1059 | 1059 |
|
| 1060 | + @unittest.skipIf(IS_PYPY, "Different behavior in PyPy") |
1060 | 1061 | def test_invalid_path(self): |
1061 | 1062 | with self.assertRaises(TypeError): |
1062 | 1063 | self.open_code(4) |
1063 | 1064 |
|
| 1065 | + @unittest.skipIf(not IS_PYPY, "Different behavior in PyPy") |
| 1066 | + def test_open_code_fd_pypy(self): |
| 1067 | + file_path = self.make_path("foo") |
| 1068 | + self.create_file(file_path, contents="test") |
| 1069 | + fd = self.os.open(file_path, os.O_RDONLY) |
| 1070 | + with self.open_code(fd) as f: |
| 1071 | + assert f.read() == b"test" |
| 1072 | + |
1064 | 1073 | def test_byte_contents_open_code(self): |
1065 | 1074 | byte_fractions = b"\xe2\x85\x93 \xe2\x85\x94 \xe2\x85\x95 \xe2\x85\x96" |
1066 | 1075 | file_path = self.make_path("foo") |
@@ -1090,6 +1099,7 @@ def setUp(self): |
1090 | 1099 | else: |
1091 | 1100 | self.open_code = self.fake_io_module.open_code |
1092 | 1101 |
|
| 1102 | + @unittest.skipIf(IS_PYPY, "Different behavior in PyPy") |
1093 | 1103 | def test_invalid_path(self): |
1094 | 1104 | with self.assertRaises(TypeError): |
1095 | 1105 | self.open_code(4) |
|
0 commit comments