From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/
Date: Wed, 29 Jun 2011 17:52:21 +0000 (UTC) [thread overview]
Message-ID: <4b45ef360b363c7fc472e6d746ee68e70ee61837.mgorny@gentoo> (raw)
commit: 4b45ef360b363c7fc472e6d746ee68e70ee61837
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 29 17:30:32 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun 29 17:32:35 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=4b45ef36
Support grabbing relevant_ and supported_eapis from a prop.
As Python doesn't supply us with class properties, we need a little
function to handle transforming them as necessary. Hopefully it won't be
an ugly hack as it uses the property object public API.
---
pmstestsuite/library/case.py | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/pmstestsuite/library/case.py b/pmstestsuite/library/case.py
index e87f15d..3ab5197 100644
--- a/pmstestsuite/library/case.py
+++ b/pmstestsuite/library/case.py
@@ -114,8 +114,20 @@ class EbuildTestCase(TestCase):
inherits = []
phase_funcs = {}
+ @classmethod
+ def _eval_prop(cls, prop_or_obj):
+ """
+ Evaluate and return the value of a property when passed a property
+ object, or return the passed value otherwise.
+ """
+
+ if isinstance(prop_or_obj, property):
+ return prop_or_obj.fget(cls)
+ else:
+ return prop_or_obj
+
@property
- def supported_eapis(self):
+ def supported_eapis(cls):
"""
A list of EAPIs for which the test is able to run and gives
predictible results. Defaults to all available EAPIs.
@@ -126,7 +138,7 @@ class EbuildTestCase(TestCase):
return (0, 1, 2, 3, 4)
@property
- def relevant_eapis(self):
+ def relevant_eapis(cls):
"""
A list of EAPIs for which the test should be run by default (in
non-thorough mode). This should list all the EAPIs where
@@ -134,7 +146,7 @@ class EbuildTestCase(TestCase):
When unset, defaults to a random element of .supported_eapis().
"""
- return random.choice(self.supported_eapis)
+ return (random.choice(cls._eval_prop(cls.supported_eapis)),)
@classmethod
def inst_all(cls, *args, **kwargs):
@@ -143,7 +155,10 @@ class EbuildTestCase(TestCase):
Returns an iterator over a list of test case instances.
"""
- for eapi in cls.relevant_eapis:
+
+ # sadly, no @classproperty
+ # but property object attributes are official
+ for eapi in cls._eval_prop(cls.relevant_eapis):
kwargs['eapi'] = eapi
yield cls(*args, **kwargs)
next reply other threads:[~2011-06-29 17:53 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-29 17:52 Michał Górny [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-01-03 15:52 [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/library/ Michał Górny
2012-01-02 22:26 Michał Górny
2011-08-12 20:55 Michał Górny
2011-08-11 22:09 Michał Górny
2011-08-11 22:09 Michał Górny
2011-08-11 8:54 Michał Górny
2011-08-11 8:53 Michał Górny
2011-08-06 14:26 Michał Górny
2011-08-06 14:25 Michał Górny
2011-08-06 14:25 Michał Górny
2011-08-03 20:17 Michał Górny
2011-08-03 20:17 Michał Górny
2011-08-03 8:17 Michał Górny
2011-08-02 18:53 Michał Górny
2011-08-02 18:53 Michał Górny
2011-08-02 18:53 Michał Górny
2011-08-02 18:53 Michał Górny
2011-07-24 14:37 Michał Górny
2011-06-29 17:52 Michał Górny
2011-06-29 17:52 Michał Górny
2011-06-29 17:52 Michał Górny
2011-06-29 17:52 Michał Górny
2011-06-29 17:52 Michał Górny
2011-06-23 21:14 [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/library/ Michał Górny
2011-06-23 21:14 Michał Górny
2011-06-20 19:20 Michał Górny
2011-06-17 15:07 Michał Górny
2011-06-17 5:59 Michał Górny
2011-06-16 19:49 Michał Górny
2011-06-16 19:49 Michał Górny
2011-06-14 12:35 Michał Górny
2011-06-14 8:32 Michał Górny
2011-06-14 8:32 Michał Górny
2011-06-13 19:16 Michał Górny
2011-06-13 19:16 Michał Górny
2011-06-07 17:22 Michał Górny
2011-06-03 17:36 Michał Górny
2011-05-31 17:19 Michał Górny
2011-05-29 18:57 Michał Górny
2011-05-29 18:57 Michał Górny
2011-05-29 18:57 Michał Górny
2011-05-29 18:17 Michał Górny
2011-05-26 7:25 Michał Górny
2011-05-26 6:35 Michał Górny
2011-05-25 20:40 Michał Górny
2011-05-24 14:28 Michał Górny
2011-05-24 8:11 Michał Górny
2011-05-24 8:11 Michał Górny
2011-05-24 8:11 Michał Górny
2011-05-23 11:52 Michał Górny
2011-05-23 9:51 Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4b45ef360b363c7fc472e6d746ee68e70ee61837.mgorny@gentoo \
--to=mgorny@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox