[jhbuild] Port some implicit relative imports



commit 54b9d2cfe4c56e2aa8ef8407d5208f231d816fc9
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Sun Sep 22 10:09:28 2019 +0200

    Port some implicit relative imports
    
    Also make the tests direcotry a package so we can do relative
    imports in there.

 Makefile.am                    |  3 ++-
 jhbuild/frontends/autobuild.py |  6 +++---
 jhbuild/frontends/gtkui.py     |  4 ++--
 jhbuild/frontends/tinderbox.py |  2 +-
 jhbuild/versioncontrol/cvs.py  |  3 ++-
 jhbuild/versioncontrol/git.py  |  5 +++--
 jhbuild/versioncontrol/svn.py  |  4 ++--
 tests/__init__.py              | 13 +++++++++++++
 tests/test_main.py             |  2 +-
 9 files changed, 29 insertions(+), 13 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 600dd8c4..5b94c736 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -30,6 +30,7 @@ EXTRA_DIST = $(PATCHES) $(MODULESETS) $(DTDS) \
        jhbuild.desktop.in.in jhbuild.desktop.in \
        tests/test_main.py \
        tests/mock.py \
+       tests/__init__.py \
        tests/autotools/autogen.sh \
        tests/autotools/configure.in \
        tests/autotools/hello.c \
@@ -57,6 +58,6 @@ install-exec-local:
        $(srcdir)/scripts/debian-python2-postinstall-hook.sh $(DESTDIR)$(bindir)
 
 check:
-       $(PYTHON) -m unittest discover -v -s $(top_srcdir)/tests
+       $(PYTHON) -m unittest discover -v -t $(top_srcdir) -s $(top_srcdir)/tests
 
 .PHONY: check
diff --git a/jhbuild/frontends/autobuild.py b/jhbuild/frontends/autobuild.py
index 9979f809..c5b99b43 100644
--- a/jhbuild/frontends/autobuild.py
+++ b/jhbuild/frontends/autobuild.py
@@ -29,14 +29,14 @@ import socket
 from jhbuild.utils import cmds, _
 from jhbuild.utils.compat import text_type, string_types
 from jhbuild.errors import CommandError
-import buildscript
+from . import buildscript
 
 import xmlrpclib
 import zlib
 from cStringIO import StringIO
 
-from tinderbox import get_distro
-from terminal import TerminalBuildScript, trayicon, t_bold, t_reset
+from .tinderbox import get_distro
+from .terminal import TerminalBuildScript, trayicon, t_bold, t_reset
 import jhbuild.moduleset
 
 def escape(string):
diff --git a/jhbuild/frontends/gtkui.py b/jhbuild/frontends/gtkui.py
index 66b0e02d..71e1e6e7 100644
--- a/jhbuild/frontends/gtkui.py
+++ b/jhbuild/frontends/gtkui.py
@@ -36,14 +36,14 @@ try:
 except ImportError:
     vte = None
 
-import buildscript
+from . import buildscript
 import jhbuild.moduleset
 from jhbuild.modtypes import MetaModule
 from jhbuild.errors import CommandError
 from jhbuild.utils import notify, _
 from jhbuild.utils.compat import string_types, cmp
 
-from terminal import t_bold, t_reset
+from .terminal import t_bold, t_reset
 
 
 class ExitRequestedException(Exception):
diff --git a/jhbuild/frontends/tinderbox.py b/jhbuild/frontends/tinderbox.py
index 93362cf4..7f80bac5 100644
--- a/jhbuild/frontends/tinderbox.py
+++ b/jhbuild/frontends/tinderbox.py
@@ -29,7 +29,7 @@ from jhbuild.utils import cmds
 from jhbuild.utils import sysid, _
 from jhbuild.errors import CommandError, FatalError
 from jhbuild.utils.compat import string_types, text_type
-import buildscript
+from . import buildscript
 
 index_header = '''<html>
   <head>
diff --git a/jhbuild/versioncontrol/cvs.py b/jhbuild/versioncontrol/cvs.py
index 91014e4f..abf6e904 100644
--- a/jhbuild/versioncontrol/cvs.py
+++ b/jhbuild/versioncontrol/cvs.py
@@ -26,7 +26,6 @@ __metaclass__ = type
 import sys
 import os
 import hashlib
-import git
 
 from jhbuild.errors import BuildStateError, CommandError
 from jhbuild.versioncontrol import Repository, Branch, register_repo_type
@@ -190,6 +189,8 @@ class CVSRepository(Repository):
 
     def branch(self, name, module=None, checkoutdir=None, revision=None,
                update_new_dirs='yes', override_checkoutdir='yes'):
+        from . import git
+
         if module is None:
             module = name
         # allow remapping of branch for module:
diff --git a/jhbuild/versioncontrol/git.py b/jhbuild/versioncontrol/git.py
index 37b2577e..82e65317 100644
--- a/jhbuild/versioncontrol/git.py
+++ b/jhbuild/versioncontrol/git.py
@@ -32,7 +32,6 @@ import logging
 from jhbuild.errors import FatalError, CommandError
 from jhbuild.utils.cmds import get_output, check_version
 from jhbuild.versioncontrol import Repository, Branch, register_repo_type
-import jhbuild.versioncontrol.svn
 from jhbuild.utils import inpath, _
 from jhbuild.utils.sxml import sxml
 
@@ -586,6 +585,8 @@ class GitSvnBranch(GitBranch):
                 extbranch._checkout(buildscript)
 
     def _checkout(self, buildscript, copydir=None):
+        from . import svn
+
         if self.config.sticky_date:
             raise FatalError(_('date based checkout not yet supported\n'))
 
@@ -595,7 +596,7 @@ class GitSvnBranch(GitBranch):
 
         # FIXME (add self.revision support)
         try:
-            last_revision = jhbuild.versioncontrol.svn.get_info (self.module)['last changed rev']
+            last_revision = svn.get_info (self.module)['last changed rev']
             if not self.revision:
                 cmd.extend(['-r', last_revision])
         except KeyError:
diff --git a/jhbuild/versioncontrol/svn.py b/jhbuild/versioncontrol/svn.py
index 27f32659..7c3e0795 100644
--- a/jhbuild/versioncontrol/svn.py
+++ b/jhbuild/versioncontrol/svn.py
@@ -32,8 +32,6 @@ from jhbuild.versioncontrol import Repository, Branch, register_repo_type
 from jhbuild.utils import inpath, _
 from jhbuild.utils.sxml import sxml
 
-import bzr, git
-
 svn_one_five = None # is this svn 1.5
 
 def _make_uri(repo, path):
@@ -130,6 +128,8 @@ class SubversionRepository(Repository):
     branch_xml_attrs = ['module', 'checkoutdir', 'revision', 'tag']
 
     def branch(self, name, module=None, checkoutdir=None, revision=None, tag=None):
+        from . import bzr, git
+
         module_href = None
         if name in self.config.branches:
             if self.config.branches[name]:
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 00000000..a9688a95
--- /dev/null
+++ b/tests/__init__.py
@@ -0,0 +1,13 @@
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
\ No newline at end of file
diff --git a/tests/test_main.py b/tests/test_main.py
index ebe45268..16660e43 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -55,7 +55,7 @@ import jhbuild.moduleset
 import jhbuild.utils.cmds
 import jhbuild.versioncontrol.tarball
 
-import mock
+from . import mock
 
 if sys.platform.startswith('win'):
     import jhbuild.utils.subprocess_win32 as subprocess_win32


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]