aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_description_tree.py16
-rw-r--r--tests/utils.py34
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