From 03d1681833ec6e40e0ba2adb760cbf4e8e4f9127 Mon Sep 17 00:00:00 2001 From: Lubomír Sedlář Date: Jul 26 2016 08:44:35 +0000 Subject: [PATCH 1/2] Remove duplicated testing code and simplify loading testing composes Signed-off-by: Lubomír Sedlář --- diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/__init__.py diff --git a/tests/helpers.py b/tests/helpers.py new file mode 100644 index 0000000..c5d9437 --- /dev/null +++ b/tests/helpers.py @@ -0,0 +1,16 @@ +# -*- encoding: utf-8 -*- + +import os +import productmd.compose + + +def get_compose_path(ident): + """Given a compose ID, return path to that compose.""" + base = os.path.dirname(__file__) + pth = os.path.join(base, 'composes', ident) + return pth + + +def get_compose(ident): + """Load a test compose and return the Compose instance.""" + return productmd.compose.Compose(get_compose_path(ident)) diff --git a/tests/test_changelog.py b/tests/test_changelog.py index 0db04c0..70c0379 100644 --- a/tests/test_changelog.py +++ b/tests/test_changelog.py @@ -1,18 +1,13 @@ # -*- encoding: utf-8 -*- import unittest -import os + +from .helpers import get_compose import productmd.compose from compose_utils.changelog import ComposeChangelog -def _get_compose_path(ident): - base = os.path.dirname(__file__) - pth = os.path.join(base, 'composes', ident) - return pth - - DUMMY_FIREFOX_SIZE = 5966 + 5934 OLD_DUMMY_FIREFOX_SIZE = 5878 + 5842 DUMMY_ELINKS_SIZE = 5850 + 5826 + 5818 @@ -53,8 +48,8 @@ DUMMY_TFTP = { class ChangelogTest(unittest.TestCase): def test_changelog(self): - old_compose = productmd.compose.Compose(_get_compose_path('DP-1.0-20160315.t.0')) - new_compose = productmd.compose.Compose(_get_compose_path('DP-1.0-20160315.t.1')) + old_compose = get_compose('DP-1.0-20160315.t.0') + new_compose = get_compose('DP-1.0-20160315.t.1') changelog = ComposeChangelog() data = changelog.get_changelog(old_compose, new_compose) @@ -119,7 +114,7 @@ class ChangelogTest(unittest.TestCase): def test_changelog_on_non_compose_dir_old(self): old_compose = productmd.compose.Compose('/tmp/not_here') - new_compose = productmd.compose.Compose(_get_compose_path('DP-1.0-20160315.t.1')) + new_compose = get_compose('DP-1.0-20160315.t.1') changelog = ComposeChangelog() with self.assertRaises(RuntimeError) as ctx: @@ -129,7 +124,7 @@ class ChangelogTest(unittest.TestCase): str(ctx.exception)) def test_changelog_on_non_compose_dir_new(self): - old_compose = productmd.compose.Compose(_get_compose_path('DP-1.0-20160315.t.0')) + old_compose = get_compose('DP-1.0-20160315.t.0') new_compose = productmd.compose.Compose('/tmp/not_here') changelog = ComposeChangelog() diff --git a/tests/test_report_move.py b/tests/test_report_move.py index 9d929a5..5c71c71 100644 --- a/tests/test_report_move.py +++ b/tests/test_report_move.py @@ -4,25 +4,20 @@ import json import unittest import os -import productmd.compose -from compose_utils.package_moves import ComposePackageMoves - +from .helpers import get_compose -def _get_compose_path(ident): - base = os.path.dirname(__file__) - pth = os.path.join(base, 'composes', ident) - return pth +from compose_utils.package_moves import ComposePackageMoves -class ChangelogTest(unittest.TestCase): +class ReportMoveTest(unittest.TestCase): def setUp(self): with open(os.path.join(os.path.dirname(__file__), 'move-report.json')) as f: self.expected = json.load(f) def test_package_moves(self): - old_compose = productmd.compose.Compose(_get_compose_path('DP-1.0-20160315.t.0')) - new_compose = productmd.compose.Compose(_get_compose_path('DP-1.0-20160315.t.2')) + old_compose = get_compose('DP-1.0-20160315.t.0') + new_compose = get_compose('DP-1.0-20160315.t.2') cpm = ComposePackageMoves() From 5ffea5524033236c824a637e33317ca06965e712 Mon Sep 17 00:00:00 2001 From: Lubomír Sedlář Date: Jul 26 2016 08:44:39 +0000 Subject: [PATCH 2/2] Fix setup.py test Kobo is distributed as a single package on PyPI, so we can't require kobo-rpmlib in setup.py. This patch also defines the test suite to use nose as a collector. Signed-off-by: Lubomír Sedlář --- diff --git a/setup.py b/setup.py index e9dec08..28739d1 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ setup( install_requires=[ 'productmd>=1.0', 'kobo', - 'kobo-rpmlib', ], include_package_data=True, + test_suite='nose.collector', )