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

Improve unit tests #191

Merged
merged 4 commits into from Feb 13, 2017
Merged

Improve unit tests #191

merged 4 commits into from Feb 13, 2017

Conversation

tstenner
Copy link
Contributor

@tstenner tstenner commented Feb 5, 2017

For an eventual py3-transition we need better unit test coverage.

What's planned / done:

  • Introduce a custom base class with better tempfile handling and asserts
  • Convert asserts / tempfile creation to use the class
  • Convert asserts from self.assert_ to more meaningful asserts (especially self.assert_(isinstance(...))
  • test for unicode / bytes explicitly

@tstenner tstenner force-pushed the test_asserts branch 3 times, most recently from 7e5af79 to f03c8b9 Compare February 5, 2017 14:46
@coveralls
Copy link

Coverage Status

Coverage remained the same at 59.188% when pulling f03c8b9 on tstenner:test_asserts into c2e3133 on bleachbit:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 59.188% when pulling f03c8b9 on tstenner:test_asserts into c2e3133 on bleachbit:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 59.188% when pulling 447a844 on tstenner:test_asserts into c2e3133 on bleachbit:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 59.111% when pulling cf59f94 on tstenner:test_asserts into c2e3133 on bleachbit:master.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 38922e7 on tstenner:test_asserts into ** on bleachbit:master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 7c6c6b9 on tstenner:test_asserts into ** on bleachbit:master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling f6d77e8 on tstenner:test_asserts into ** on bleachbit:master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 77c3f78 on tstenner:test_asserts into ** on bleachbit:master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 1bc6410 on tstenner:test_asserts into ** on bleachbit:master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling f4c46b6 on tstenner:test_asserts into ** on bleachbit:master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling a0e2540 on tstenner:test_asserts into ** on bleachbit:master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling a75a5ef on tstenner:test_asserts into ** on bleachbit:master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling c925c41 on tstenner:test_asserts into ** on bleachbit:master**.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 59.111% when pulling 9ec8306 on tstenner:test_asserts into 391f08b on bleachbit:master.



class AssertFile:
class BleachbitTestCase(unittest.TestCase):
Copy link
Member

Choose a reason for hiding this comment

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

It's a good idea to use inheritance here

cmd = 'cmd.exe /c dir'
if 'posix' == os.name:
cmd = 'dir'
cmds = {'nt': 'cmd.exe /c dir', 'posix': 'dir'}
Copy link
Member

Choose a reason for hiding this comment

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

This is a creative use of a dictionary. Nice.

self.assert_(os.path.exists(path))
self.assert_(os.path.getsize(path) > 0)
self.assertExists(path)
self.assertGreater(os.path.getsize(path), 0)
Copy link
Member

Choose a reason for hiding this comment

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

assertGreater is another benefit of Python 2.7+

for test in tests_undo:
self.assertEqual(extended_path_undo(test[0]), test[1])
for short, extended in tests:
# already extended path shouldn't be changed
Copy link
Member

Choose a reason for hiding this comment

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

These are logical tests

@coveralls
Copy link

Coverage Status

Coverage remained the same at 59.188% when pulling ed370d5 on tstenner:test_asserts into 391f08b on bleachbit:master.

@az0
Copy link
Member

az0 commented Feb 8, 2017

This is great work. I love a cleanup like this that reduces code.

I could merge this now, but would you rather wait? I see only 2/4 items are checked off.

@ROCKNROLLKID
Copy link
Contributor

I am seeing merge conflicts with this. Will need to fix that first.

@tstenner
Copy link
Contributor Author

tstenner commented Feb 8, 2017

I'd rather go through the last remaining files first and then rebase the PR, after that I'd also be in favor of merging it (less conflicts for me and everyone else). I can always open another PR for the remaining items.

@ROCKNROLLKID
Copy link
Contributor

Are we holding back Python 3 coding for the next update then?

@az0
Copy link
Member

az0 commented Feb 9, 2017

@tstenner OK, please write a note when it's ready.

@ROCKNROLLKID I would like to hold major changes including Python 3 and GTK 3 until after BleachBit 2.0 is released. Then it may also take a follow-up maintenance release to fix important regressions. After that I would like to evaluate how well Python 3 and GTK 3 work, especially on Windows. Given the recent work to shrink the new GTK 2 on Windows for BleachBit 2.0, I assume that I can also shrink Python 3 and GTK 3. This pull request is a stepping stone for Python 3 because it improves test coverage.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 59.058% when pulling 77d91c8 on tstenner:test_asserts into 83d09cc on bleachbit:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 59.058% when pulling 772a35f on tstenner:test_asserts into 83d09cc on bleachbit:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 59.058% when pulling 06f95f4 on tstenner:test_asserts into 83d09cc on bleachbit:master.

@tstenner tstenner force-pushed the test_asserts branch 2 times, most recently from 2a01aef to 0aa45ad Compare February 10, 2017 07:34
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 58.917% when pulling 0aa45ad on tstenner:test_asserts into 66271f4 on bleachbit:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 58.993% when pulling 70674c2 on tstenner:test_asserts into 66271f4 on bleachbit:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 58.993% when pulling 37d3e12 on tstenner:test_asserts into 66271f4 on bleachbit:master.

@tstenner
Copy link
Contributor Author

The test for locked files fails because the worker reports that it cleaned too many bytes (6 instead of 3), but I (think I) didn't change anything relevant in the failing test. Could someone with a windows installation take a look at it?

@az0
Copy link
Member

az0 commented Feb 11, 2017

The error 6 != 3 looks like something I broke related to the new WindowsWipe code. I will work on it.

@az0
Copy link
Member

az0 commented Feb 11, 2017

The 6 != 3 error was fixed in commit 193e07a

@tstenner tstenner force-pushed the test_asserts branch 2 times, most recently from 7e8380a to 984ee27 Compare February 12, 2017 07:21
@tstenner
Copy link
Contributor Author

The unit tests pass now, travis hits a time limit somehow (downloading the appveyor artifacts?). We should merge this, I'll tackle the rest of the todo-list in a separate PR

@az0 az0 merged commit c164a0d into bleachbit:master Feb 13, 2017
@az0
Copy link
Member

az0 commented Feb 13, 2017

Yes, Travis hit a time limit waiting on AppVeyor, while Appveyor failed because of the errno typo.

@tstenner tstenner deleted the test_asserts branch February 13, 2017 09:25
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.

None yet

4 participants