MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_fspath_set_to_None

Method test_fspath_set_to_None

Lib/test/test_os.py:5475–5512  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5473 self.assertNotHasAttr(A(), '__dict__')
5474
5475 def test_fspath_set_to_None(self):
5476 class Foo:
5477 __fspath__ = None
5478
5479 class Bar:
5480 def __fspath__(self):
5481 return 'bar'
5482
5483 class Baz(Bar):
5484 __fspath__ = None
5485
5486 good_error_msg = (
5487 r"expected str, bytes or os.PathLike object, not {}".format
5488 )
5489
5490 with self.assertRaisesRegex(TypeError, good_error_msg("Foo")):
5491 self.fspath(Foo())
5492
5493 self.assertEqual(self.fspath(Bar()), 'bar')
5494
5495 with self.assertRaisesRegex(TypeError, good_error_msg("Baz")):
5496 self.fspath(Baz())
5497
5498 with self.assertRaisesRegex(TypeError, good_error_msg("Foo")):
5499 open(Foo())
5500
5501 with self.assertRaisesRegex(TypeError, good_error_msg("Baz")):
5502 open(Baz())
5503
5504 other_good_error_msg = (
5505 r"should be string, bytes or os.PathLike, not {}".format
5506 )
5507
5508 with self.assertRaisesRegex(TypeError, other_good_error_msg("Foo")):
5509 os.rename(Foo(), "foooo")
5510
5511 with self.assertRaisesRegex(TypeError, other_good_error_msg("Baz")):
5512 os.rename(Baz(), "bazzz")
5513
5514class TimesTests(unittest.TestCase):
5515 def test_times(self):

Callers

nothing calls this directly

Calls 7

assertRaisesRegexMethod · 0.80
FooClass · 0.70
BarClass · 0.70
BazClass · 0.70
openFunction · 0.50
assertEqualMethod · 0.45
renameMethod · 0.45

Tested by

no test coverage detected