GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-98393: Update test_os for bytes-like types by vstinner · Pull Request #98487 · python/cpython

gh-98393: Update test_os for bytes-like types #98487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
vstinner merged 1 commit into python:main from vstinner:test_os
Nov 2, 2022

Uh oh!

There was an error while loading. Please reload this page.

Merged

gh-98393: Update test_os for bytes-like types #98487

Changes from all commits
Commits
Show all changes
1 commit
Select commit
fee1750
gh-98393: Update test_os for bytes-like types
vstinner Oct 20, 2022
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

46 changes: 12 additions & 34 deletions 46 Lib/test/test_os.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3797,8 +3797,6 @@ class Str(str):
else:
encoded = os.fsencode(os_helper.TESTFN)
self.bytes_filenames.append(encoded)
self.bytes_filenames.append(bytearray(encoded))
self.bytes_filenames.append(memoryview(encoded))

self.filenames = self.bytes_filenames + self.unicode_filenames

Expand All @@ -3810,21 +3808,10 @@ def test_oserror_filename(self):
(self.filenames, os.rmdir,),
(self.filenames, os.stat,),
(self.filenames, os.unlink,),
(self.filenames, os.listdir,),
(self.filenames, os.rename, "dst"),
(self.filenames, os.replace, "dst"),
]
if sys.platform == "win32":
funcs.extend((
(self.bytes_filenames, os.rename, b"dst"),
(self.bytes_filenames, os.replace, b"dst"),
(self.unicode_filenames, os.rename, "dst"),
(self.unicode_filenames, os.replace, "dst"),
(self.unicode_filenames, os.listdir, ),
))
else:
funcs.extend((
(self.filenames, os.listdir,),
(self.filenames, os.rename, "dst"),
(self.filenames, os.replace, "dst"),
))
if os_helper.can_chmod():
funcs.append((self.filenames, os.chmod, 0o777))
if hasattr(os, "chown"):
Expand All @@ -3840,11 +3827,7 @@ def test_oserror_filename(self):
if hasattr(os, "chroot"):
funcs.append((self.filenames, os.chroot,))
if hasattr(os, "link"):
if sys.platform == "win32":
funcs.append((self.bytes_filenames, os.link, b"dst"))
funcs.append((self.unicode_filenames, os.link, "dst"))
else:
funcs.append((self.filenames, os.link, "dst"))
funcs.append((self.filenames, os.link, "dst"))
if hasattr(os, "listxattr"):
funcs.extend((
(self.filenames, os.listxattr,),
Expand All @@ -3857,21 +3840,16 @@ def test_oserror_filename(self):
if hasattr(os, "readlink"):
funcs.append((self.filenames, os.readlink,))


for filenames, func, *func_args in funcs:
for name in filenames:
if not isinstance(name, (str, bytes)):
with self.assertRaises(TypeError):
func(name, *func_args)
try:
func(name, *func_args)
except OSError as err:
self.assertIs(err.filename, name, str(func))
except UnicodeDecodeError:
pass
else:
try:
func(name, *func_args)
except OSError as err:
self.assertIs(err.filename, name, str(func))
except UnicodeDecodeError:
pass
else:
self.fail("No exception thrown by {}".format(func))
self.fail(f"No exception thrown by {func}")

class CPUCountTests(unittest.TestCase):
def test_cpu_count(self):
Expand Down Expand Up @@ -4351,7 +4329,7 @@ def test_bytes_like(self):
for cls in bytearray, memoryview:
path_bytes = cls(os.fsencode(self.path))
with self.assertRaises(TypeError):
list(os.scandir(path_bytes))
os.scandir(path_bytes)

@unittest.skipUnless(os.listdir in os.supports_fd,
'fd support for listdir required for this test.')
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.