Skip to content
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.

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

bpo-39488: skip bigfile test if not enough disk space #18261

Open
wants to merge 3 commits into
base: master
from

Conversation

@giampaolo
Copy link
Contributor

giampaolo commented Jan 29, 2020

@@ -151,9 +151,23 @@ def test_seekable(self):
self.assertTrue(f.seekable())


def skip_no_disk_space():

This comment has been minimized.

Copy link
@vstinner

vstinner Jan 29, 2020

Member

I would prefer to pass explicitly a path, and call it inside the test, not outside (decorator).

Well, like a regular function :-) skip_no_disk_space(path, required).

This comment has been minimized.

Copy link
@giampaolo

giampaolo Jan 29, 2020

Author Contributor

I would prefer to pass explicitly a path

Agree. Done.

and call it inside the test, not outside (decorator).

The check is executed right before running the test (and not on module import). Or at least, I guess that is your concern (it was mine too).

class TestCopyfile(LargeFileTest, unittest.TestCase):
open = staticmethod(io.open)

@skip_no_disk_space(os.getcwd(), size * 3)

This comment has been minimized.

Copy link
@vstinner

vstinner Jan 30, 2020

Member

os.getcwd() can be different when the function is defined and when the test is executed. I suggested to call skip_no_disk_space() inside the function. Something like:

def test_it(self):
    skip_no_disk_space(TESTFN, size * 3)
    ...

TESTFN is usually relative. I'm not sure if skip_no_disk_space() should be made absolute using os.path.abspath().

This comment has been minimized.

Copy link
@giampaolo

giampaolo Jan 30, 2020

Author Contributor

Good point. I used os.path.realpath instead.

class TestCopyfile(LargeFileTest, unittest.TestCase):
open = staticmethod(io.open)

@skip_no_disk_space(TESTFN, size * 3)

This comment has been minimized.

Copy link
@vstinner

vstinner Jan 30, 2020

Member

Why is it *3? I count only two files: TESTFN and TESTFN2. Maybe add a comment explaining why it's *3?

@@ -200,6 +213,7 @@ def run(sock):
self.thread.start()
event.set()

@skip_no_disk_space(TESTFN, size * 3)

This comment has been minimized.

Copy link
@vstinner

vstinner Jan 30, 2020

Member

Same question here :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.