]> git.samba.org - jelmer/dulwich.git/commitdiff
Fix the tutorial tests on python3. Fixes: #573
authorJelmer Vernooij <jelmer@jelmer.uk>
Thu, 12 Apr 2018 22:23:45 +0000 (23:23 +0100)
committerJelmer Vernooij <jelmer@jelmer.uk>
Thu, 12 Apr 2018 22:23:45 +0000 (23:23 +0100)
Makefile
NEWS
docs/tutorial/object-store.txt
docs/tutorial/remote.txt
docs/tutorial/repo.txt
dulwich/tests/__init__.py

index 39886c225a0c1a2c89645df5c9149299be042339..372be39fb57eb48272d1e97f487edeb58804f9e3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ FLAKE8 ?= flake8
 SETUP = $(PYTHON) setup.py
 PYDOCTOR ?= pydoctor
 TESTRUNNER ?= unittest
-RUNTEST = PYTHONHASHSEED=random PYTHONPATH=.:$(PYTHONPATH) $(PYTHON) -m $(TESTRUNNER) $(TEST_OPTIONS)
+RUNTEST = PYTHONHASHSEED=random PYTHONPATH=$(shell pwd):$(PYTHONPATH) $(PYTHON) -m $(TESTRUNNER) $(TEST_OPTIONS)
 COVERAGE = python3-coverage
 
 DESTDIR=/
diff --git a/NEWS b/NEWS
index 6f0bb2f5c0b97a106fe9f8ecf88aa38afdd93a23..befe4e69f56bf5bb3f8b40b322c8daf35cc64a5a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,8 @@
 
   * Fix handling of encoding for tags. (Jelmer Vernooij, #608)
 
+  * Fix tutorial tests on Python 3. (Jelmer Vernooij, #573)
+
 0.19.2 2018-04-07
 
  BUG FIXES
index 580b174889bb4cc4f93f73c2af2f5e3cb29de621..b1746d3df99eb4bf6c7fd6127f0609f24e07d78d 100644 (file)
@@ -169,8 +169,10 @@ The diff between the previous head and the new one can be printed using
 write_tree_diff::
 
   >>> from dulwich.patch import write_tree_diff
-  >>> import sys
-  >>> write_tree_diff(sys.stdout, repo.object_store, commit.tree, tree.id)
+  >>> from io import BytesIO
+  >>> out = BytesIO()
+  >>> write_tree_diff(out, repo.object_store, commit.tree, tree.id)
+  >>> import sys; _ = sys.stdout.write(out.getvalue().decode('ascii'))
   diff --git a/spam b/spam
   index c55063a..16ee268 100644
   --- a/spam
index 0f40a627644a8ef2359e8183591bb29d19097421..727c3f41e30aac0f3396ed5fe7aaa630e44c86f2 100644 (file)
@@ -5,7 +5,7 @@ Most of the tests in this file require a Dulwich server, so let's start one:
     >>> from dulwich.repo import Repo
     >>> from dulwich.server import DictBackend, TCPGitServer
     >>> import threading
-    >>> repo = Repo.init(b"remote", mkdir=True)
+    >>> repo = Repo.init("remote", mkdir=True)
     >>> cid = repo.do_commit(b"message", committer=b"Jelmer <jelmer@samba.org>")
     >>> backend = DictBackend({b'/': repo})
     >>> dul_server = TCPGitServer(backend, b'localhost', 0)
@@ -32,7 +32,7 @@ Dulwich provides support for accessing remote repositories in
 one manually::
 
    >>> from dulwich.client import TCPGitClient
-   >>> client = TCPGitClient(server_address.encode('ascii'), server_port)
+   >>> client = TCPGitClient(server_address, server_port)
 
 Retrieving raw pack files
 -------------------------
@@ -76,7 +76,7 @@ in which case Dulwich takes care of providing the right graph walker, and
 importing the received pack file into the local repository::
 
    >>> from dulwich.repo import Repo
-   >>> local = Repo.init(b"local", mkdir=True)
+   >>> local = Repo.init("local", mkdir=True)
    >>> remote_refs = client.fetch(b"/", local)
 
 Let's shut down the server now that all tests have been run::
index 72840b0a32b57157ba2794f2bf5237187c4285bd..1597ea3e3c7bdfba7b33b82081f40dde57f06e69 100644 (file)
@@ -53,7 +53,7 @@ so only non-bare repositories will have an index, too. To open the index, simply
 call::
 
     >>> index = repo.open_index()
-    >>> print(index.path.decode(sys.getfilesystemencoding()))
+    >>> print(index.path)
     myrepo/.git/index
 
 Since the repository was just created, the index will be empty::
index 6e9e5b5d241ec6fb607ae1f962ce45678d72b1f2..daed1f1157cece8413a11250c1f0f0554e6de37e 100644 (file)
@@ -159,9 +159,8 @@ def tutorial_test_suite():
 def nocompat_test_suite():
     result = unittest.TestSuite()
     result.addTests(self_test_suite())
+    result.addTests(tutorial_test_suite())
     from dulwich.contrib import test_suite as contrib_test_suite
-    if sys.version_info[0] == 2:
-        result.addTests(tutorial_test_suite())
     result.addTests(contrib_test_suite())
     return result
 
@@ -176,7 +175,7 @@ def compat_test_suite():
 def test_suite():
     result = unittest.TestSuite()
     result.addTests(self_test_suite())
-    if sys.version_info[0] == 2 and sys.platform != 'win32':
+    if sys.platform != 'win32':
         result.addTests(tutorial_test_suite())
     from dulwich.tests.compat import test_suite as compat_test_suite
     result.addTests(compat_test_suite())