diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2010-05-27 19:56:06 -0300 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2010-05-27 19:56:06 -0300 |
commit | 6023a1e4aafbc2aa7062451693fccfe5a5b5572b (patch) | |
tree | 3a655c8ef1f8d77bff04399ca45beae697df14fb | |
parent | Added tests to g_octave/description_tree.py (tests/test_description_tree.py) (diff) | |
download | g-octave-6023a1e4aafbc2aa7062451693fccfe5a5b5572b.tar.gz g-octave-6023a1e4aafbc2aa7062451693fccfe5a5b5572b.tar.bz2 g-octave-6023a1e4aafbc2aa7062451693fccfe5a5b5572b.zip |
moved the snippet of code that creates a "fake" DESCRIPTION tree from tests/test_description_tree.py to
tests/utils.py, because this will be used by another test suite.
-rw-r--r-- | tests/test_description_tree.py | 16 | ||||
-rw-r--r-- | tests/utils.py | 34 |
2 files changed, 36 insertions, 14 deletions
diff --git a/tests/test_description_tree.py b/tests/test_description_tree.py index 0eb305c..a8f0d50 100644 --- a/tests/test_description_tree.py +++ b/tests/test_description_tree.py @@ -13,8 +13,8 @@ import os import shutil -import tempfile import unittest +import utils from g_octave import description, description_tree @@ -30,19 +30,7 @@ class TestDescriptionTree(unittest.TestCase): ] def setUp(self): - description_file = os.path.join( - os.path.dirname(os.path.abspath(__file__)), 'DESCRIPTION' - ) - - # creating a temporary DESCRIPTION's tree - self._tree_dir = tempfile.mkdtemp() - for cat, pkg, ver in self._packages: - temp_path = os.path.join(self._tree_dir, cat, pkg+'-'+ver) - os.makedirs(temp_path) - shutil.copy( - description_file, - os.path.join(temp_path, 'DESCRIPTION') - ) + self._tree_dir = utils.create_description_tree(self._packages) self._tree = description_tree.DescriptionTree(self._tree_dir) def test_temptree(self): diff --git a/tests/utils.py b/tests/utils.py new file mode 100644 index 0000000..a0bf86c --- /dev/null +++ b/tests/utils.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" + utils.py + ~~~~~~~~ + + module with helper functions to the test suites. + + :copyright: (c) 2010 by Rafael Goncalves Martins + :license: GPL-2, see LICENSE for more details. +""" + +import os +import shutil +import tempfile + +def create_description_tree(packages): + # 'packages' is a list of tuples, like this: + # [(category, name, version)] + description_file = os.path.join( + os.path.dirname(os.path.abspath(__file__)), 'DESCRIPTION' + ) + + # creating a temporary DESCRIPTION's tree + tree_dir = tempfile.mkdtemp() + for cat, pkg, ver in packages: + temp_path = os.path.join(tree_dir, cat, pkg+'-'+ver) + os.makedirs(temp_path) + shutil.copy( + description_file, + os.path.join(temp_path, 'DESCRIPTION') + ) + return tree_dir |