From f5d11b750ecc982541d1f936488248f0b42d75d3 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 20:15:50 +0100 Subject: pep8 linting (whitespaces) W191 indentation contains tabs E221 multiple spaces before operator E222 multiple spaces after operator E225 missing whitespace around operator E271 multiple spaces after keyword W292 no newline at end of file W293 blank line contains whitespace W391 blank line at end of file --- git/test/lib/helper.py | 64 +++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'git/test/lib/helper.py') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index a76f1a15..4f8cdf33 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -32,22 +32,22 @@ def absolute_project_path(): return os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) #} END routines - + #{ Adapters - + class StringProcessAdapter(object): """Allows to use strings as Process object as returned by SubProcess.Popen. Its tailored to work with the test system only""" - + def __init__(self, input_string): self.stdout = cStringIO.StringIO(input_string) self.stderr = cStringIO.StringIO() - + def wait(self): return 0 - + poll = wait - + #} END adapters #{ Decorators @@ -66,7 +66,7 @@ def _rmtree_onerror(osremove, fullpath, exec_info): """ if os.name != 'nt' or osremove is not os.remove: raise - + os.chmod(fullpath, 0777) os.remove(fullpath) @@ -74,9 +74,9 @@ def with_rw_repo(working_tree_ref, bare=False): """ Same as with_bare_repo, but clones the rorepo as non-bare repository, checking out the working tree at the given working_tree_ref. - + This repository type is more costly due to the working copy checkout. - + To make working with relative paths easier, the cwd will be set to the working dir of the repository. """ @@ -89,12 +89,12 @@ def with_rw_repo(working_tree_ref, bare=False): #END handle prefix repo_dir = _mktemp("%sbare_%s" % (prefix, func.__name__)) rw_repo = self.rorepo.clone(repo_dir, shared=True, bare=bare, n=True) - + rw_repo.head.commit = rw_repo.commit(working_tree_ref) if not bare: rw_repo.head.reference.checkout() # END handle checkout - + prev_cwd = os.getcwd() os.chdir(rw_repo.working_dir) try: @@ -116,7 +116,7 @@ def with_rw_repo(working_tree_ref, bare=False): return repo_creator # END argument passer return argument_passer - + def with_rw_and_rw_remote_repo(working_tree_ref): """ Same as with_rw_repo, but also provides a writable remote repository from which the @@ -124,20 +124,20 @@ def with_rw_and_rw_remote_repo(working_tree_ref): run the remote_repo. The remote repository was cloned as bare repository from the rorepo, wheras the rw repo has a working tree and was cloned from the remote repository. - + remote_repo has two remotes: origin and daemon_origin. One uses a local url, the other uses a server url. The daemon setup must be done on system level and should be an inetd service that serves tempdir.gettempdir() and all directories in it. - + The following scetch demonstrates this:: rorepo ------> rw_remote_repo ------> rw_repo - + The test case needs to support the following signature:: def case(self, rw_repo, rw_remote_repo) - + This setup allows you to test push and pull scenarios and hooks nicely. - + See working dir info in with_rw_repo """ assert isinstance(working_tree_ref, basestring), "Decorator requires ref name for working tree checkout" @@ -145,15 +145,15 @@ def with_rw_and_rw_remote_repo(working_tree_ref): def remote_repo_creator(self): remote_repo_dir = _mktemp("remote_repo_%s" % func.__name__) repo_dir = _mktemp("remote_clone_non_bare_repo") - + rw_remote_repo = self.rorepo.clone(remote_repo_dir, shared=True, bare=True) rw_repo = rw_remote_repo.clone(repo_dir, shared=True, bare=False, n=True) # recursive alternates info ? rw_repo.head.commit = working_tree_ref rw_repo.head.reference.checkout() - + # prepare for git-daemon rw_remote_repo.daemon_export = True - + # this thing is just annoying ! crw = rw_remote_repo.config_writer() section = "daemon" @@ -164,16 +164,16 @@ def with_rw_and_rw_remote_repo(working_tree_ref): crw.set(section, "receivepack", True) # release lock del(crw) - + # initialize the remote - first do it as local remote and pull, then # we change the url to point to the daemon. The daemon should be started # by the user, not by us d_remote = Remote.create(rw_repo, "daemon_origin", remote_repo_dir) d_remote.fetch() remote_repo_url = "git://localhost%s" % remote_repo_dir - + d_remote.config_writer.set('url', remote_repo_url) - + # try to list remotes to diagnoes whether the server is up try: rw_repo.git.ls_remote(d_remote) @@ -185,7 +185,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref): raise AssertionError('Please start a git-daemon to run this test, execute: git-daemon "%s"' % os.path.dirname(_mktemp())) # END make assertion #END catch ls remote error - + # adjust working dir prev_cwd = os.getcwd() os.chdir(rw_repo.working_dir) @@ -203,29 +203,29 @@ def with_rw_and_rw_remote_repo(working_tree_ref): return remote_repo_creator # END remote repo creator # END argument parsser - + return argument_passer - + #} END decorators - + class TestBase(TestCase): """ Base Class providing default functionality to all tests such as: - + - Utility functions provided by the TestCase base of the unittest method such as:: self.fail("todo") self.failUnlessRaises(...) - + - Class level repository which is considered read-only as it is shared among all test cases in your type. Access it using:: self.rorepo # 'ro' stands for read-only - + The rorepo is in fact your current project's git repo. If you refer to specific shas for your objects, be sure you choose some that are part of the immutable portion of the project history ( to assure tests don't fail for others ). """ - + @classmethod def setUpClass(cls): """ @@ -233,7 +233,7 @@ class TestBase(TestCase): each test type has its own repository """ cls.rorepo = Repo(GIT_REPO) - + def _make_file(self, rela_path, data, repo=None): """ Create a file at the given path relative to our repository, filled -- cgit v1.2.3 From be34ec23c48d6d5d8fd2ef4491981f6fb4bab8e6 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 20:51:04 +0100 Subject: pep8 linting (blank lines expectations) E301 expected 1 blank line, found 0 E302 expected 2 blank lines, found 1 E303 too many blank lines (n) --- git/test/lib/helper.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'git/test/lib/helper.py') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 4f8cdf33..d5045ad7 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -21,13 +21,16 @@ __all__ = ( #{ Routines + def fixture_path(name): test_dir = os.path.dirname(os.path.dirname(__file__)) return os.path.join(test_dir, "fixtures", name) + def fixture(name): return open(fixture_path(name), 'rb').read() + def absolute_project_path(): return os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")) @@ -35,7 +38,9 @@ def absolute_project_path(): #{ Adapters + class StringProcessAdapter(object): + """Allows to use strings as Process object as returned by SubProcess.Popen. Its tailored to work with the test system only""" @@ -52,6 +57,7 @@ class StringProcessAdapter(object): #{ Decorators + def _mktemp(*args): """Wrapper around default tempfile.mktemp to fix an osx issue""" tdir = tempfile.mktemp(*args) @@ -59,6 +65,7 @@ def _mktemp(*args): tdir = '/private' + tdir return tdir + def _rmtree_onerror(osremove, fullpath, exec_info): """ Handle the case on windows that read-only files cannot be deleted by @@ -70,6 +77,7 @@ def _rmtree_onerror(osremove, fullpath, exec_info): os.chmod(fullpath, 0777) os.remove(fullpath) + def with_rw_repo(working_tree_ref, bare=False): """ Same as with_bare_repo, but clones the rorepo as non-bare repository, checking @@ -81,6 +89,7 @@ def with_rw_repo(working_tree_ref, bare=False): dir of the repository. """ assert isinstance(working_tree_ref, basestring), "Decorator requires ref name for working tree checkout" + def argument_passer(func): def repo_creator(self): prefix = 'non_' @@ -117,6 +126,7 @@ def with_rw_repo(working_tree_ref, bare=False): # END argument passer return argument_passer + def with_rw_and_rw_remote_repo(working_tree_ref): """ Same as with_rw_repo, but also provides a writable remote repository from which the @@ -141,6 +151,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref): See working dir info in with_rw_repo """ assert isinstance(working_tree_ref, basestring), "Decorator requires ref name for working tree checkout" + def argument_passer(func): def remote_repo_creator(self): remote_repo_dir = _mktemp("remote_repo_%s" % func.__name__) @@ -208,7 +219,9 @@ def with_rw_and_rw_remote_repo(working_tree_ref): #} END decorators + class TestBase(TestCase): + """ Base Class providing default functionality to all tests such as: -- cgit v1.2.3 From 614907b7445e2ed8584c1c37df7e466e3b56170f Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 20:56:53 +0100 Subject: pep8 linting (whitespace before/after) E201 whitespace after '(' E202 whitespace before ')' E203 whitespace before ':' E225 missing whitespace around operator E226 missing whitespace around arithmetic operator E227 missing whitespace around bitwise or shift operator E228 missing whitespace around modulo operator E231 missing whitespace after ',' E241 multiple spaces after ',' E251 unexpected spaces around keyword / parameter equals --- git/test/lib/helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git/test/lib/helper.py') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index d5045ad7..812aecdc 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -188,7 +188,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref): # try to list remotes to diagnoes whether the server is up try: rw_repo.git.ls_remote(d_remote) - except GitCommandError,e: + except GitCommandError, e: print str(e) if os.name == 'nt': raise AssertionError('git-daemon needs to run this test, but windows does not have one. Otherwise, run: git-daemon "%s"' % os.path.dirname(_mktemp())) -- cgit v1.2.3 From c8e70749887370a99adeda972cc3503397b5f9a7 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 21:09:47 +0100 Subject: pep8 linting (trailing whitespace) W291 trailing whitespace --- git/test/lib/helper.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'git/test/lib/helper.py') diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 812aecdc..913cf3b6 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -36,7 +36,7 @@ def absolute_project_path(): #} END routines -#{ Adapters +#{ Adapters class StringProcessAdapter(object): @@ -55,7 +55,7 @@ class StringProcessAdapter(object): #} END adapters -#{ Decorators +#{ Decorators def _mktemp(*args): @@ -68,7 +68,7 @@ def _mktemp(*args): def _rmtree_onerror(osremove, fullpath, exec_info): """ - Handle the case on windows that read-only files cannot be deleted by + Handle the case on windows that read-only files cannot be deleted by os.remove by setting it to mode 777, then retry deletion. """ if os.name != 'nt' or osremove is not os.remove: @@ -80,12 +80,12 @@ def _rmtree_onerror(osremove, fullpath, exec_info): def with_rw_repo(working_tree_ref, bare=False): """ - Same as with_bare_repo, but clones the rorepo as non-bare repository, checking + Same as with_bare_repo, but clones the rorepo as non-bare repository, checking out the working tree at the given working_tree_ref. This repository type is more costly due to the working copy checkout. - To make working with relative paths easier, the cwd will be set to the working + To make working with relative paths easier, the cwd will be set to the working dir of the repository. """ assert isinstance(working_tree_ref, basestring), "Decorator requires ref name for working tree checkout" @@ -130,14 +130,14 @@ def with_rw_repo(working_tree_ref, bare=False): def with_rw_and_rw_remote_repo(working_tree_ref): """ Same as with_rw_repo, but also provides a writable remote repository from which the - rw_repo has been forked as well as a handle for a git-daemon that may be started to + rw_repo has been forked as well as a handle for a git-daemon that may be started to run the remote_repo. - The remote repository was cloned as bare repository from the rorepo, wheras + The remote repository was cloned as bare repository from the rorepo, wheras the rw repo has a working tree and was cloned from the remote repository. - remote_repo has two remotes: origin and daemon_origin. One uses a local url, - the other uses a server url. The daemon setup must be done on system level - and should be an inetd service that serves tempdir.gettempdir() and all + remote_repo has two remotes: origin and daemon_origin. One uses a local url, + the other uses a server url. The daemon setup must be done on system level + and should be an inetd service that serves tempdir.gettempdir() and all directories in it. The following scetch demonstrates this:: @@ -176,7 +176,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref): # release lock del(crw) - # initialize the remote - first do it as local remote and pull, then + # initialize the remote - first do it as local remote and pull, then # we change the url to point to the daemon. The daemon should be started # by the user, not by us d_remote = Remote.create(rw_repo, "daemon_origin", remote_repo_dir) @@ -191,7 +191,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref): except GitCommandError, e: print str(e) if os.name == 'nt': - raise AssertionError('git-daemon needs to run this test, but windows does not have one. Otherwise, run: git-daemon "%s"' % os.path.dirname(_mktemp())) + raise AssertionError('git-daemon needs to run this test, but windows does not have one. Otherwise, run: git-daemon "%s"' % os.path.dirname(_mktemp())) else: raise AssertionError('Please start a git-daemon to run this test, execute: git-daemon "%s"' % os.path.dirname(_mktemp())) # END make assertion @@ -229,20 +229,20 @@ class TestBase(TestCase): self.fail("todo") self.failUnlessRaises(...) - - Class level repository which is considered read-only as it is shared among + - Class level repository which is considered read-only as it is shared among all test cases in your type. - Access it using:: + Access it using:: self.rorepo # 'ro' stands for read-only - The rorepo is in fact your current project's git repo. If you refer to specific - shas for your objects, be sure you choose some that are part of the immutable portion + The rorepo is in fact your current project's git repo. If you refer to specific + shas for your objects, be sure you choose some that are part of the immutable portion of the project history ( to assure tests don't fail for others ). """ @classmethod def setUpClass(cls): """ - Dynamically add a read-only repository to our actual type. This way + Dynamically add a read-only repository to our actual type. This way each test type has its own repository """ cls.rorepo = Repo(GIT_REPO) -- cgit v1.2.3