Skip to content

Conversation

@janneronkko
Copy link
Contributor

Previously if you created file having larger initial contents than the
free space in the fake filesystem, the disk usage counter was decreased
by the size of the initial contents possibly resulting in negative usage.

Basically the issue was that when ChangeDiskUsage is called with size
larger than the amount of free space, space usage is not changed but
an error is raised. Due to an exception, CreateFile removes the created
object that results in new call to ChangeDiskUsage with negative size
of the object.

Previously the object's size was set before ChangeDiskUsage was called
and then when the object was being removed the object's already set size
was used to reduce the filesystem usage (even though that size was never
added to the usage).

dest.write('a' * total_size)

self.assertEqual(total_size, self.fs.GetDiskUsage('/mount').used)

Copy link
Member

@mrbean-bremen mrbean-bremen Feb 2, 2017

Choose a reason for hiding this comment

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

Looks nice - thanks! Nice to know that I am not the only one using this feature :)
Could you please move this test to the class DiskSpaceTest in fake_filesystem_test.py (fake_filesystem_unitest_test.py is used for unit test/patcher related tests) and rename it to conform to the used style (e.g. camel case for test names - seems to be Google's coding style) - I will merge it afterwards.

Previously if you created file having larger initial contents than the
free space in the fake filesystem, the disk usage counter was decreased
by the size of the initial contents possibly resulting in negative usage.

Basically the issue was that when ChangeDiskUsage is called with size
larger than the amount of free space, space usage is not changed but
an error is raised. Due to an exception, CreateFile removes the created
object that results in new call to ChangeDiskUsage with negative size
of the object.

Previously the object's size was set before ChangeDiskUsage was called
and then when the object was being removed the object's already set size
was used to reduce the filesystem usage (even though that size was never
added to the usage).
@janneronkko
Copy link
Contributor Author

Did the update go unnoticed or is there still something that I should fix?

@mrbean-bremen
Copy link
Member

@jannero - sorry, for some reason I didn't get notified about your change.

@mrbean-bremen mrbean-bremen merged commit 298a692 into pytest-dev:master Feb 7, 2017
@mrbean-bremen
Copy link
Member

And thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants