summaryrefslogtreecommitdiff
path: root/git/test/test_docs.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-19 18:53:40 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-19 18:53:40 +0100
commite395ac90bf088ad6b5de7dadb6531a6e7f3f4f3f (patch)
tree7dcf36f94c9f5ca6ca22c2a70d68c9a0a7440ece /git/test/test_docs.py
parent048ffa58468521c043de567f620003457b8b3dbe (diff)
downloadgitpython-e395ac90bf088ad6b5de7dadb6531a6e7f3f4f3f.tar.gz
Added tutorial about initializing a repository.
Additionally, for this and future examples, there is a test_doc.py suite to contain all code mentioned in the docs. That way, we know if things stop working. Fixes #236
Diffstat (limited to 'git/test/test_docs.py')
-rw-r--r--git/test/test_docs.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/git/test/test_docs.py b/git/test/test_docs.py
new file mode 100644
index 00000000..5ebae513
--- /dev/null
+++ b/git/test/test_docs.py
@@ -0,0 +1,26 @@
+#-*-coding:utf-8-*-
+# test_git.py
+# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
+#
+# This module is part of GitPython and is released under
+# the BSD License: http://www.opensource.org/licenses/bsd-license.php
+import os
+
+import git
+from git.test.lib import TestBase
+from gitdb.test.lib import with_rw_directory
+from git.repo.fun import touch
+
+
+class TestGit(TestBase):
+
+ @with_rw_directory
+ def test_add_file_and_commit(self, rw_dir):
+ repo_dir = os.path.join(rw_dir, 'my-new-repo')
+ file_name = os.path.join(repo_dir, 'new-file')
+
+ r = git.Repo.init(repo_dir)
+ # This function just creates an empty file ...
+ touch(file_name)
+ r.index.add([file_name])
+ r.index.commit("initial commit")