diff options
author | Michal Minar <miminar@redhat.com> | 2013-12-18 18:28:03 +0100 |
---|---|---|
committer | Michal Minar <miminar@redhat.com> | 2013-12-19 09:52:28 +0100 |
commit | 723afb3805925d856976034acb221da02c99610a (patch) | |
tree | ede324cc629e7d376c635d53be1fda5b74744101 /src/software | |
parent | dac1d1ac6de74e30b1e62d90a9b936c087de0b28 (diff) | |
download | openlmi-providers-723afb3805925d856976034acb221da02c99610a.tar.gz openlmi-providers-723afb3805925d856976034acb221da02c99610a.tar.xz openlmi-providers-723afb3805925d856976034acb221da02c99610a.zip |
software: fixed tests behaviour under nosetests
Test cases under nosetests did not behave well. The part of class setup
method was not called due to faulty checking of test case instantiation.
It caused not-testing repositories to be enabled during running all but
first test.
This patch ensures that all not-testing repositories are disabled during
subsequents test runs.
If anyhing is missing upon intialization, testing database is recreated.
Diffstat (limited to 'src/software')
-rw-r--r-- | src/software/test/swbase.py | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/software/test/swbase.py b/src/software/test/swbase.py index c06158b..a7d8e3c 100644 --- a/src/software/test/swbase.py +++ b/src/software/test/swbase.py @@ -152,8 +152,6 @@ def test_with_packages(*install_pkgs, **enable_dict): raise ValueError( 'invalid format of repo#package string: "%s"' % repopkg) - #if func.__name__ in ('test_install_package_same_arch', 'test_install_package'): - #import pdb; pdb.set_trace() to_remove = package.filter_installed_packages( to_remove.union(set(p.name for p in to_install))) package.remove_pkgs(to_remove) @@ -238,25 +236,27 @@ class SwTestCase(LmiTestCase): SwTestCase._cleanup_db = ( os.environ.get('LMI_SOFTWARE_CLEANUP_CACHE', '1') in ('1', 'yes', 'on', 'true')) - if not getattr(SwTestCase, 'repodb', False): + if SwTestCase.TEST_CASES_INSTANTIATED == 0: if os.environ.get('LMI_SOFTWARE_DB_CACHE', None): db_cache = os.environ['LMI_SOFTWARE_DB_CACHE'] SwTestCase.repos_dir, SwTestCase.repodb, \ SwTestCase.other_repos = \ reposetup.load_test_database(db_cache) - else: + if ( not hasattr(SwTestCase, 'repos_dir') + or not os.path.exists(SwTestCase.repos_dir) + or any( not os.path.exists(r.config_path) + for r in cls.repodb.values())): SwTestCase.repos_dir = tempfile.mkdtemp() SwTestCase.repodb, SwTestCase.other_repos = \ reposetup.make_object_database(SwTestCase.repos_dir) - if not getattr(SwTestCase, '_restore_repos', []): - SwTestCase._restore_repos = [] - for repoid in repository.get_repo_list('enabled'): - if repoid in SwTestCase.other_repos \ - and repository.is_repo_enabled(repoid): - SwTestCase._restore_repos.append(repoid) - repository.set_repos_enabled(SwTestCase._restore_repos, False) - for repoid in SwTestCase._restore_repos: - SwTestCase.other_repos[repoid].refresh() + SwTestCase._restore_repos = [] + for repoid in repository.get_repo_list('enabled'): + if repoid in SwTestCase.other_repos \ + and repository.is_repo_enabled(repoid): + SwTestCase._restore_repos.append(repoid) + repository.set_repos_enabled(SwTestCase._restore_repos, False) + for repoid in SwTestCase._restore_repos: + SwTestCase.other_repos[repoid].refresh() SwTestCase.TEST_CASES_INSTANTIATED += 1 @classmethod |