MCPcopy Index your code
hub / github.com/python/cpython / test_exists

Method test_exists

Lib/test/test_genericpath.py:136–167  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

134 )
135
136 def test_exists(self):
137 filename = os_helper.TESTFN
138 bfilename = os.fsencode(filename)
139 self.addCleanup(os_helper.unlink, filename)
140
141 self.assertIs(self.pathmodule.exists(filename), False)
142 self.assertIs(self.pathmodule.exists(bfilename), False)
143
144 self.assertIs(self.pathmodule.lexists(filename), False)
145 self.assertIs(self.pathmodule.lexists(bfilename), False)
146
147 create_file(filename)
148
149 self.assertIs(self.pathmodule.exists(filename), True)
150 self.assertIs(self.pathmodule.exists(bfilename), True)
151
152 self.assertIs(self.pathmodule.exists(filename + '\udfff'), False)
153 self.assertIs(self.pathmodule.exists(bfilename + b'\xff'), False)
154 self.assertIs(self.pathmodule.exists(filename + '\x00'), False)
155 self.assertIs(self.pathmodule.exists(bfilename + b'\x00'), False)
156
157 self.assertIs(self.pathmodule.lexists(filename), True)
158 self.assertIs(self.pathmodule.lexists(bfilename), True)
159
160 self.assertIs(self.pathmodule.lexists(filename + '\udfff'), False)
161 self.assertIs(self.pathmodule.lexists(bfilename + b'\xff'), False)
162 self.assertIs(self.pathmodule.lexists(filename + '\x00'), False)
163 self.assertIs(self.pathmodule.lexists(bfilename + b'\x00'), False)
164
165 # Keyword arguments are accepted
166 self.assertIs(self.pathmodule.exists(path=filename), True)
167 self.assertIs(self.pathmodule.lexists(path=filename), True)
168
169 @unittest.skipUnless(hasattr(os, "pipe"), "requires os.pipe()")
170 def test_exists_fd(self):

Callers

nothing calls this directly

Calls 5

addCleanupMethod · 0.80
create_fileFunction · 0.70
assertIsMethod · 0.45
existsMethod · 0.45
lexistsMethod · 0.45

Tested by

no test coverage detected