summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2016-10-13 14:04:18 -0700
committerDylan Baker <dylan@pnwbakers.com>2016-11-10 10:49:09 -0800
commit0a1cd0013f6726669d9b73482658fd454d94536c (patch)
treee5f78454126574088c046c13617743e8cb1cc226 /unittests
parent2385a07cf4e0de347bb7dacb8749aea7023387e8 (diff)
framework/profile: add a copy method to profile
This will allow a profile to be copied and "subclassed" without affecting the original profile. This will allow a long-standing bug that made it impossible to run two subclasses of all.py (say shader.py and glslparser.py) at the same time, since they would both try to modify the all.py profile in incompatible ways. Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Diffstat (limited to 'unittests')
-rw-r--r--unittests/framework/test_profile.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/unittests/framework/test_profile.py b/unittests/framework/test_profile.py
index 66713497b..5ef95e4c3 100644
--- a/unittests/framework/test_profile.py
+++ b/unittests/framework/test_profile.py
@@ -285,6 +285,58 @@ class TestTestProfile(object):
assert grouptools.join('foo', 'abc') in self.profile.test_list
+ class TestCopy(object):
+ """Tests for the copy method."""
+
+ @pytest.fixture
+ def fixture(self):
+ orig = profile.TestProfile()
+ orig.test_list['foo'] = utils.Test(['foo'])
+ orig.test_list['bar'] = utils.Test(['bar'])
+ orig.filters = [lambda name, _: name != 'bar']
+ orig.forced_test_list = ['foo']
+ return orig
+
+ def test_filters(self, fixture):
+ """The filters attribute is copied correctly."""
+ new = fixture.copy()
+
+ # Assert that the fixtures are equivalent, but not the same
+ assert fixture.filters == new.filters
+ assert fixture.filters is not new.filters
+
+ # And double check by modifying one of them and asserting that the
+ # other has not changed.
+ new.filters.append(lambda name, _: name != 'oink')
+ assert len(fixture.filters) == 1
+
+ def test_forced_test_list(self, fixture):
+ """The forced_test_list attribute is copied correctly."""
+ new = fixture.copy()
+
+ # Assert that the fixtures are equivalent, but not the same
+ assert fixture.forced_test_list == new.forced_test_list
+ assert fixture.forced_test_list is not new.forced_test_list
+
+ # And double check by modifying one of them and asserting that the
+ # other has not changed.
+ del new.forced_test_list[0]
+ assert fixture.forced_test_list[0] == 'foo'
+
+ def test_test_list(self, fixture):
+ """The test_list attribute is copied correctly."""
+ new = fixture.copy()
+
+ # Assert that the fixtures are equivalent, but not the same
+ assert fixture.test_list == new.test_list
+ assert fixture.test_list is not new.test_list
+
+ def test_prepare_test_list(self, fixture):
+ """The prepare_test_list method doesn't affect both."""
+ new = fixture.copy()
+ new.prepare_test_list()
+ assert new.test_list != fixture.test_list
+
class TestTestDict(object):
"""Tests for the TestDict object."""