diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2011-05-30 21:14:22 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2011-05-30 21:23:17 +0200 |
commit | 6f960586feccff8c1f2c717765eb0a5e8b9cd6f3 (patch) | |
tree | a1c9e6eca585cd7db760ddbd23aacadde6d8d1d4 /git/test/test_import.py | |
parent | 7fab60c596cdd2588f9c7b2b4eb9f93f8736b915 (diff) | |
download | gitpython-6f960586feccff8c1f2c717765eb0a5e8b9cd6f3.tar.gz |
Fixed remaining tests as good as possible. remote/fetch/pull and submodule tests need some more work. Also, the tests need to be reorganized and move closer to their actual location within gitpython. Hence the refs tests go to git.test.refs, etc
Diffstat (limited to 'git/test/test_import.py')
-rw-r--r-- | git/test/test_import.py | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/git/test/test_import.py b/git/test/test_import.py index d97cee55..a5a1d11b 100644 --- a/git/test/test_import.py +++ b/git/test/test_import.py @@ -6,9 +6,53 @@ module, by importing using from x import *""" # perform the actual imports +import os -from nose import SkipTest +from git import * + +def import_all(topdir, topmodule='git', skip = "test"): + base = os.path.basename + join = os.path.join + init_script = '__init__.py' + prev_cwd = os.getcwd() + try: + os.chdir(os.path.dirname(topdir)) + for root, dirs, files in os.walk(base(topdir)): + if init_script not in files: + del(dirs[:]) + continue + #END ignore non-packages + + if skip in root: + continue + #END handle ignores + + for relafile in files: + if not relafile.endswith('.py'): + continue + if relafile == init_script: + continue + module_path = join(root, os.path.splitext(relafile)[0]).replace("/", ".").replace("\\", ".") + + m = __import__(module_path, globals(), locals(), [""]) + try: + attrlist = m.__all__ + for attr in attrlist: + assert hasattr(m, attr), "Invalid item in %s.__all__: %s" % (module_path, attr) + #END veriy + except AttributeError: + pass + # END try each listed attribute + #END for each file in dir + #END for each item + finally: + os.chdir(prev_cwd) + #END handle previous currentdir + + class TestDummy(object): def test_base(self): - raise SkipTest("todo") + dn = os.path.dirname + # NOTE: i don't think this is working, as the __all__ variable is not used in this case + import_all(dn(dn(__file__))) |