diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2010-05-29 03:47:08 -0300 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2010-05-29 03:47:08 -0300 |
commit | 152e1a07d0afd2e50dd6897d88ed0d848d003390 (patch) | |
tree | cafed64da5e816859ef07471f9448f508cce5d1f /tests | |
parent | removed the method to create a g_octave.DescriptionTree object from the modul... (diff) | |
download | g-octave-152e1a07d0afd2e50dd6897d88ed0d848d003390.tar.gz g-octave-152e1a07d0afd2e50dd6897d88ed0d848d003390.tar.bz2 g-octave-152e1a07d0afd2e50dd6897d88ed0d848d003390.zip |
fixed tests to g_octave.overlay. added tests to g_octave.ebuild (tests/test_ebuild.py)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_ebuild.py | 57 | ||||
-rw-r--r-- | tests/test_overlay.py | 34 |
2 files changed, 63 insertions, 28 deletions
diff --git a/tests/test_ebuild.py b/tests/test_ebuild.py new file mode 100644 index 0000000..5e0c629 --- /dev/null +++ b/tests/test_ebuild.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" + test_ebuild.py + ~~~~~~~~~~~~~~ + + test suite for the *g_octave.ebuild* module + + :copyright: (c) 2010 by Rafael Goncalves Martins + :license: GPL-2, see LICENSE for more details. +""" + +import unittest +import utils + +from g_octave import ebuild + + +class TestEbuild(unittest.TestCase): + + def setUp(self): + self._config, self._config_file, self._dir = utils.create_env() + + def test_re_keywords(self): + keywords = [ + ('alpha', (None, 'alpha')), + ('amd64', (None, 'amd64')), + ('hppa', (None, 'hppa')), + ('ppc', (None, 'ppc')), + ('ppc64', (None, 'ppc64')), + ('sparc', (None, 'sparc')), + ('x86', (None, 'x86')), + ('~alpha', ('~', 'alpha')), + ('~amd64', ('~', 'amd64')), + ('~hppa', ('~', 'hppa')), + ('~ppc', ('~', 'ppc')), + ('~ppc64', ('~', 'ppc64')), + ('~sparc', ('~', 'sparc')), + ('~x86', ('~', 'x86')), + ] + + for kwstr, kwtpl in keywords: + match = ebuild.re_keywords.match(kwstr) + self.assertEqual( + (match.group(1), match.group(2)), + kwtpl + ) + + def tearDown(self): + utils.clean_env(self._config_file, self._dir) + + +def suite(): + suite = unittest.TestSuite() + suite.addTest(TestEbuild('test_re_keywords')) + return suite diff --git a/tests/test_overlay.py b/tests/test_overlay.py index 6d33edc..9242324 100644 --- a/tests/test_overlay.py +++ b/tests/test_overlay.py @@ -16,6 +16,7 @@ import os import shutil import tempfile import unittest +import utils from g_octave import config, overlay @@ -23,36 +24,14 @@ from g_octave import config, overlay class TestOverlay(unittest.TestCase): def setUp(self): - self._config_file = tempfile.mkstemp(suffix='.cfg')[1] - self._dir = tempfile.mkdtemp() - - # the directories doesn't need to be created. the config module - # will do this - self._db = os.path.join(self._dir, 'db') - self._cache = os.path.join(self._dir, 'cache') - self._overlay = os.path.join(self._dir, 'overlay') - - cp = ConfigParser.ConfigParser() - cp.add_section('main') - cp.set('main', 'db', self._db) - cp.set('main', 'cache', self._cache) - cp.set('main', 'overlay', self._overlay) - - with open(self._config_file, 'w') as fp: - cp.write(fp) - - self._config = config.Config( - fetch_phase = True, - config_file = self._config_file, - create_dirs = True - ) + self._config, self._config_file, self._dir = utils.create_env() def test_overlay(self): overlay.create_overlay(conf = self._config, quiet = True) files = { - os.path.join(self._overlay, 'eclass', 'octave-forge.eclass'): '', - os.path.join(self._overlay, 'profiles', 'repo_name'): 'g-octave', - os.path.join(self._overlay, 'profiles', 'categories'): 'g-octave', + os.path.join(self._config.overlay, 'eclass', 'octave-forge.eclass'): '', + os.path.join(self._config.overlay, 'profiles', 'repo_name'): 'g-octave', + os.path.join(self._config.overlay, 'profiles', 'categories'): 'g-octave', } for _file in files: self.assertTrue(os.path.exists(_file)) @@ -60,8 +39,7 @@ class TestOverlay(unittest.TestCase): self.assertEqual(fp.read(), files[_file]) def tearDown(self): - shutil.rmtree(self._dir) - os.unlink(self._config_file) + utils.clean_env(self._config_file, self._dir) def suite(): |