From 32a91b6f42b1380fb1bc8fdf852ca3b9365a2927 Mon Sep 17 00:00:00 2001
From: Jonas Haag <jonas@lophus.org>
Date: Mon, 9 May 2016 11:18:44 +0200
Subject: [PATCH] Python 3 ctags support

---
 klaus/repo.py          |  6 +++---
 test_requirements.txt  |  2 +-
 tests/test_make_app.py | 12 +++++-------
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/klaus/repo.py b/klaus/repo.py
index 97d5b19..3ab506b 100644
--- a/klaus/repo.py
+++ b/klaus/repo.py
@@ -96,9 +96,9 @@ class FancyRepo(dulwich.repo.Repo):
 
     def get_tag_and_branch_shas(self):
         """Return a list of SHAs of all tags and branches."""
-        tag_shas = self.refs.as_dict('refs/tags/').values()
-        branch_shas = self.refs.as_dict('refs/heads/').values()
-        return tag_shas + branch_shas
+        tag_shas = self.refs.as_dict(b'refs/tags/').values()
+        branch_shas = self.refs.as_dict(b'refs/heads/').values()
+        return set(tag_shas) | set(branch_shas)
 
     def history(self, commit, path=None, max_commits=None, skip=0):
         """Return a list of all commits that affected `path`, starting at branch
diff --git a/test_requirements.txt b/test_requirements.txt
index 64420ba..9634e7c 100644
--- a/test_requirements.txt
+++ b/test_requirements.txt
@@ -1,4 +1,4 @@
 pytest
 requests
-python-ctags; python_version < '3' # not supported on Python 3
+python-ctags3
 mock; python_version < '3'
diff --git a/tests/test_make_app.py b/tests/test_make_app.py
index 58da9bd..b1fb281 100644
--- a/tests/test_make_app.py
+++ b/tests/test_make_app.py
@@ -13,9 +13,6 @@ import requests.auth
 from .utils import *
 
 
-xfail_py3 = pytest.mark.xfail(sys.version_info[0] >= 3, reason="not supported on Python 3")
-
-
 def test_htdigest_file_without_smarthttp_or_require_browser_auth():
     with pytest.raises(ValueError):
         klaus.make_app([], None, htdigest_file=object())
@@ -84,14 +81,14 @@ test_ctags_disabled = options_test(
     {},
     {'ctags_tags_and_branches': False, 'ctags_all': False}
 )
-test_ctags_tags_and_branches = xfail_py3(options_test(
+test_ctags_tags_and_branches = options_test(
     {'ctags_policy': 'tags-and-branches'},
     {'ctags_tags_and_branches': True, 'ctags_all': False}
-))
-test_ctags_all = xfail_py3(options_test(
+)
+test_ctags_all = options_test(
     {'ctags_policy': 'ALL'},
     {'ctags_tags_and_branches': True, 'ctags_all': True}
-))
+)
 
 
 # Reach
@@ -155,6 +152,7 @@ def ctags_all():
 
 def _ctags_enabled(ref, filename):
     response = requests.get(UNAUTH_TEST_REPO_URL + "blob/%s/%s" % (ref, filename))
+    assert response.status_code == 200, response.text
     href = '<a href="/%sblob/%s/%s#L-1">' % (TEST_REPO_URL, ref, filename)
     return href in response.text
 
-- 
GitLab