1 |
commit: 6ae2cc8860a8e9f637c01a727fdeba582b878c78 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Aug 3 08:09:38 2011 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Aug 3 08:09:38 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=6ae2cc88 |
7 |
|
8 |
Migrate most of the tests to use assertions. |
9 |
|
10 |
--- |
11 |
pmstestsuite/library/standard/eclass_metadata.py | 13 +++---- |
12 |
.../library/standard/phase_function_order.py | 4 +- |
13 |
pmstestsuite/library/standard/special_vars.py | 33 ++++++++++--------- |
14 |
3 files changed, 25 insertions(+), 25 deletions(-) |
15 |
|
16 |
diff --git a/pmstestsuite/library/standard/eclass_metadata.py b/pmstestsuite/library/standard/eclass_metadata.py |
17 |
index 4e5ed15..1ebc05e 100644 |
18 |
--- a/pmstestsuite/library/standard/eclass_metadata.py |
19 |
+++ b/pmstestsuite/library/standard/eclass_metadata.py |
20 |
@@ -41,12 +41,11 @@ class IUseInheritanceTest(VariableInheritanceTest): |
21 |
|
22 |
def check_dbus_result(self, output, pm): |
23 |
# ensure it got installed first |
24 |
- if not DBusEclassTestCase.check_dbus_result(self, output, pm): |
25 |
- return False |
26 |
+ DBusEclassTestCase.check_dbus_result(self, output, pm) |
27 |
|
28 |
spl = pm.installed[self.atom(pm)].use |
29 |
- return self.var_eclass_value in spl \ |
30 |
- and self.var_ebuild_value in spl |
31 |
+ self.assertEqual(sorted(spl), sorted((self.var_eclass_value, |
32 |
+ self.var_ebuild_value)), 'IUSE') |
33 |
|
34 |
# XXX: REQUIRED_USE |
35 |
|
36 |
@@ -71,8 +70,8 @@ EXPORT_FUNCTIONS src_compile |
37 |
''' % self.pn |
38 |
|
39 |
def check_dbus_result(self, output, pm): |
40 |
- if not DBusEclassTestCase.check_dbus_result(self, output, pm): |
41 |
- return False |
42 |
+ DBusEclassTestCase.check_dbus_result(self, output, pm) |
43 |
|
44 |
phases = pm.installed[self.atom(pm)].defined_phases |
45 |
- return (sorted(phases) == ['compile', 'setup']) |
46 |
+ self.assertEqual(sorted(phases), ['compile', 'setup'], |
47 |
+ 'DEFINED_PHASES') |
48 |
|
49 |
diff --git a/pmstestsuite/library/standard/phase_function_order.py b/pmstestsuite/library/standard/phase_function_order.py |
50 |
index ce7f03f..65209ce 100644 |
51 |
--- a/pmstestsuite/library/standard/phase_function_order.py |
52 |
+++ b/pmstestsuite/library/standard/phase_function_order.py |
53 |
@@ -42,5 +42,5 @@ src_install |
54 |
pkg_preinst |
55 |
pkg_postinst""" |
56 |
|
57 |
- return (output == expect) \ |
58 |
- and DBusEbuildTestCase.check_dbus_result(self, output, pm) |
59 |
+ DBusEbuildTestCase.check_dbus_result(self, output, pm) |
60 |
+ self.assertEqual(output, expect, 'Executed phases') |
61 |
|
62 |
diff --git a/pmstestsuite/library/standard/special_vars.py b/pmstestsuite/library/standard/special_vars.py |
63 |
index eab61dc..854a196 100644 |
64 |
--- a/pmstestsuite/library/standard/special_vars.py |
65 |
+++ b/pmstestsuite/library/standard/special_vars.py |
66 |
@@ -14,9 +14,10 @@ class InheritedVariableTest(DBusEbuildTestCase): |
67 |
} |
68 |
|
69 |
def check_dbus_result(self, output, pm): |
70 |
+ DBusEbuildTestCase.check_dbus_result(self, output, pm) |
71 |
inherits = output.split() |
72 |
- return 'pms-test-dbus' in inherits \ |
73 |
- and DBusEbuildTestCase.check_dbus_result(self, output, pm) |
74 |
+ self.assertContains('pms-test-dbus', inherits, |
75 |
+ 'INHERITS') |
76 |
|
77 |
class RDependFallbackTest(DBusEbuildTestCase): |
78 |
""" Test whether RDEPEND=${DEPEND} fallback works as expected. """ |
79 |
@@ -28,20 +29,21 @@ class RDependFallbackTest(DBusEbuildTestCase): |
80 |
} |
81 |
|
82 |
def check_dbus_result(self, output, pm): |
83 |
- # in EAPI 4, expect empty RDEPEND |
84 |
- # in older EAPIs, expect DEPEND |
85 |
- |
86 |
- if not DBusEbuildTestCase.check_dbus_result(self, output, pm): |
87 |
- return False |
88 |
+ DBusEbuildTestCase.check_dbus_result(self, output, pm) |
89 |
|
90 |
- def _has_our_pkg(deps): |
91 |
- for d in deps: |
92 |
- if d.key == 'virtual/libc': |
93 |
- return True |
94 |
- return False |
95 |
+ class DepMatcher(object): |
96 |
+ def __eq__(self, other): |
97 |
+ return other.key == 'virtual/libc' |
98 |
|
99 |
rdep = pm.installed[self.atom(pm)].run_dependencies |
100 |
- return ((self.eapi == 4) != _has_our_pkg(rdep)) |
101 |
+ mydep = DepMatcher() |
102 |
+ |
103 |
+ # in EAPI 4, expect empty RDEPEND |
104 |
+ # in older EAPIs, expect == DEPEND |
105 |
+ if self.eapi == 4: |
106 |
+ self.assertEqual(tuple(rdep), (), 'RDEPEND') |
107 |
+ else: |
108 |
+ self.assertContains(mydep, rdep, 'RDEPEND') |
109 |
|
110 |
class DefinedPhasesTest(DBusEbuildTestCase): |
111 |
""" Test whether DEFINED_PHASES are declared in EAPI 4. """ |
112 |
@@ -54,8 +56,7 @@ class DefinedPhasesTest(DBusEbuildTestCase): |
113 |
} |
114 |
|
115 |
def check_dbus_result(self, output, pm): |
116 |
- if not DBusEbuildTestCase.check_dbus_result(self, output, pm): |
117 |
- return False |
118 |
+ DBusEbuildTestCase.check_dbus_result(self, output, pm) |
119 |
|
120 |
phases = pm.installed[self.atom(pm)].defined_phases |
121 |
- return (str(phases) == 'setup') |
122 |
+ self.assertEqual(tuple(phases), ('setup',), 'DEFINED_PHASES') |