← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/turnip:fix-tests into turnip:master

 

Colin Watson has proposed merging ~cjwatson/turnip:fix-tests into turnip:master.

Commit message:
Fix test failures in some less-usual configurations

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/turnip/+git/turnip/+merge/383623

The tests failed under LC_ALL=C, or when not running from a git checkout (as was the case in the Mojo CI payload tests).
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/turnip:fix-tests into turnip:master.
diff --git a/turnip/api/store.py b/turnip/api/store.py
index 934dd71..5723048 100644
--- a/turnip/api/store.py
+++ b/turnip/api/store.py
@@ -341,8 +341,11 @@ def get_refs(repo_store, repo_name, exclude_prefixes=None):
             try:
                 ref = ref_obj.name
                 if isinstance(ref, bytes):
+                    ref_bytes = ref
                     ref = ref.decode('utf-8')
-                git_object = repo.references[ref].peel()
+                else:
+                    ref_bytes = ref.encode('utf-8')
+                git_object = repo.references[ref_bytes].peel()
             except UnicodeDecodeError:
                 pass
             else:
diff --git a/turnip/pack/tests/test_hooks.py b/turnip/pack/tests/test_hooks.py
index 4e793da..746214e 100644
--- a/turnip/pack/tests/test_hooks.py
+++ b/turnip/pack/tests/test_hooks.py
@@ -173,7 +173,8 @@ class HookTestMixin(object):
                 self.hook_path, [self.hook_path],
                 env={
                     b'TURNIP_HOOK_RPC_SOCK': self.hookrpc_sock_path,
-                    b'TURNIP_HOOK_RPC_KEY': key})
+                    b'TURNIP_HOOK_RPC_KEY': key},
+                path=self.repo_dir)
             code, stdout, stderr = yield d
         finally:
             self.hookrpc_handler.unregisterKey(key)