Skip to content

Conversation

@giampaolo
Copy link
Contributor

@giampaolo giampaolo commented Jan 29, 2020

self.assertTrue(f.seekable())


def skip_no_disk_space():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

@skip_no_disk_space(TESTFN, size * 3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just for extra safety. The required exact disk space would be (file size * 2) (aka 4.7G), but just in case something else writes on disk (especially on builtbots) I opted for (file size * 3) (around 7.2 GB).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment:

    # Exact required disk space would be (size * 2), but let's give it a
    # bit more tolerance.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If size2 is enough, I suggest to use size2.5 for safety rather than size*3 which is quite huge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Done.

self.thread.start()
event.set()

@skip_no_disk_space(TESTFN, size * 3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind to copy/paste the command here (and also replace size * 3 with size * 2.5)?

@vstinner vstinner merged commit b39fb8e into python:master Feb 5, 2020
@vstinner
Copy link
Member

vstinner commented Feb 5, 2020

Thanks @giampaolo! I tested manually your PR and it works as expected.

I merged your PR immediately, since I'm still getting https://bugs.python.org/issue39488 failure frequently on buildbots. Let's see if it's enough to fix these buildbots.

@giampaolo
Copy link
Contributor Author

Let's see. =)

@giampaolo giampaolo deleted the bigfile-skip branch February 5, 2020 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants