def test_testdict_allow_reassignment(): """TestDict: allow_reassignment works.""" test = profile.TestDict() test['a'] = utils.Test(['foo']) with test.allow_reassignment: test['a'] = utils.Test(['bar']) nt.ok_(test['a'].command == ['bar'])
def test_testdict_value_not_valid(): """TestDict: If the value isn't a Tree, Test, or None an exception is raised. Like the key test this isn't perfect, but it does try the common mistakes. """ test = profile.TestDict() for x in [{}, 'a']: test['foo'] = x
def setup(self): """Setup each test.""" self.data = profile.TestDict() self.data[grouptools.join('group1', 'test1')] = \ utils.Test(['thingy']) self.data[grouptools.join('group1', 'group3', 'test2')] = \ utils.Test(['thing']) self.data[grouptools.join('group3', 'test5')] = \ utils.Test(['other']) self.data[grouptools.join('group4', 'Test9')] = \ utils.Test(['is_caps']) self.opts = self.__patcher.start()
def test_testdict_key_not_string(): """TestDict: If key value isn't a string an exception is raised. This throws a few different things at the key value and expects an error to be raised. It isn't a perfect test, but it was the best I could come up with. """ test = profile.TestDict() for x in [None, utils.Test(['foo']), ['a'], {'a': 1}]: test[x] = utils.Test(['foo'])
def test_testprofile_allow_reassignemnt_stacked(): """profile.TestDict.allow_reassignment: check stacking cornercase. There is an odd corner case in the original (obvious) implmentation of this function, If one opens two context managers and then returns from the inner one assignment will not be allowed, even though one is still inside the first context manager. """ test = profile.TestDict() test['a'] = utils.Test(['foo']) with test.allow_reassignment: with test.allow_reassignment: pass test['a'] = utils.Test(['bar']) nt.ok_(test['a'].command == ['bar'])
'include_tests': 'gl-2.0', 'exclude_tests': '', 'target_rate': 50, }, } def _maketest(res): """Helper utility to make a test with a result.""" t = utils.Test(['foo']) t.result.result = res return t PROFILE = profile.TestProfile() PROFILE.test_list = profile.TestDict() PROFILE.test_list['[email protected]@a'] = _maketest('pass') PROFILE.test_list['[email protected]@b'] = _maketest('warn') PROFILE.test_list['[email protected]@c'] = _maketest('pass') PROFILE.test_list['[email protected]@d'] = _maketest('fail') PROFILE.test_list['[email protected]@a'] = _maketest('fail') PROFILE.test_list['[email protected]@b'] = _maketest('crash') PROFILE.test_list['[email protected]@c'] = _maketest('pass') PROFILE.test_list['[email protected]@d'] = _maketest('fail') class TestFeatResult(object): """Tests for the FeatResult class.""" @pytest.fixture(scope='session') def feature(self, tmpdir_factory): p = tmpdir_factory.mktemp('feature').join('p')
def inst(self): return profile.TestDict()
def setup(self): self.test = profile.TestDict()
def test_testdict_reassignment_lower(): """TestDict: reassigning a key raises an exception (capitalization is ignored).""" test = profile.TestDict() test['foo'] = utils.Test(['foo']) test['Foo'] = utils.Test(['foo', 'bar'])
def test_testdict_reassignment(): """TestDict: reassigning a key raises an exception.""" test = profile.TestDict() test['foo'] = utils.Test(['foo']) test['foo'] = utils.Test(['foo', 'bar'])