diff options
| author | Kostis Anagnostopoulos <ankostis@gmail.com> | 2016-10-24 17:32:06 +0200 |
|---|---|---|
| committer | Kostis Anagnostopoulos <ankostis@gmail.com> | 2016-10-24 18:26:06 +0200 |
| commit | 534c9bbe320f638153f9ffd79b79fa124b544d0f (patch) | |
| tree | 731c56781e2b0bf367919ed8a0ef7e0a61f6a200 /gitdb/test/db | |
| parent | 08b1f5f4fdc95d4ce24aa33ec82ac0d9723b8a02 (diff) | |
| download | gitdb-2.1.0.dev1.tar.gz | |
fix(win): FIX and HIDE 2 win-errors remainingv2.1.0.dev1
+ File-in-use errors were fixed with `gitdb.util.mman.collect()`!
+ This call is disabled `gitdb.util.HIDE_WINDOWS_KNOWN_ERRORS == False`.
+ Depend on latest smmp `v2.1.0.dev1` tag
Diffstat (limited to 'gitdb/test/db')
| -rw-r--r-- | gitdb/test/db/lib.py | 10 | ||||
| -rw-r--r-- | gitdb/test/db/test_git.py | 3 | ||||
| -rw-r--r-- | gitdb/test/db/test_pack.py | 10 |
3 files changed, 17 insertions, 6 deletions
diff --git a/gitdb/test/db/lib.py b/gitdb/test/db/lib.py index 528bcc1..d7365ea 100644 --- a/gitdb/test/db/lib.py +++ b/gitdb/test/db/lib.py @@ -39,7 +39,7 @@ class TestDBBase(TestBase): # data two_lines = b'1234\nhello world' - all_data = (two_lines, ) + all_data = (two_lines,) def _assert_object_writing_simple(self, db): # write a bunch of objects and query their streams and info @@ -56,10 +56,10 @@ class TestDBBase(TestBase): assert isinstance(info, OInfo) assert info.type == istream.type and info.size == istream.size - stream = db.stream(istream.binsha) - assert isinstance(stream, OStream) - assert stream.binsha == info.binsha and stream.type == info.type - assert stream.read() == data + with db.stream(istream.binsha) as stream: + assert isinstance(stream, OStream) + assert stream.binsha == info.binsha and stream.type == info.type + assert stream.read() == data # END for each item assert db.size() == null_objs + ni diff --git a/gitdb/test/db/test_git.py b/gitdb/test/db/test_git.py index acc0f15..b637c13 100644 --- a/gitdb/test/db/test_git.py +++ b/gitdb/test/db/test_git.py @@ -24,7 +24,8 @@ class TestGitDB(TestDBBase): # access should be possible gitdb_sha = next(gdb.sha_iter()) assert isinstance(gdb.info(gitdb_sha), OInfo) - assert isinstance(gdb.stream(gitdb_sha), OStream) + with gdb.stream(gitdb_sha) as stream: + assert isinstance(gdb.stream(gitdb_sha), OStream) ni = 50 assert gdb.size() >= ni sha_list = list(gdb.sha_iter()) diff --git a/gitdb/test/db/test_pack.py b/gitdb/test/db/test_pack.py index b361a59..f7e631e 100644 --- a/gitdb/test/db/test_pack.py +++ b/gitdb/test/db/test_pack.py @@ -13,10 +13,16 @@ from gitdb.exc import BadObject, AmbiguousObjectName import os import random +from gitdb.util import mman, HIDE_WINDOWS_KNOWN_ERRORS class TestPackDB(TestDBBase): + ## Unless HIDE_WINDOWS_KNOWN_ERRORS, on Windows fails with: + # File "D:\Work\gitdb.git\gitdb\test\db\test_pack.py", line 41, in test_writing + # os.rename(pack_path, new_pack_path) + # PermissionError: [WinError 32] The process cannot access the file + # because it is being used by another process: 'pack-c0438c19fb16422b6bbcce24387b3264416d485b.packrenamed' @with_rw_directory @with_packs_rw def test_writing(self, path): @@ -30,6 +36,10 @@ class TestPackDB(TestDBBase): # packs removed - rename a file, should affect the glob pack_path = pdb.entities()[0].pack().path() new_pack_path = pack_path + "renamed" + ## FIXME: Had to manually collect leaked files!! + if HIDE_WINDOWS_KNOWN_ERRORS: + leaked_mmaps = mman.collect() + self.assertEqual(leaked_mmaps, 6) os.rename(pack_path, new_pack_path) pdb.update_cache(force=True) |
