Esempio n. 1
0
    def test_mocks_mock_property(self) -> None:
        '''torment.fixtures.register({}, (), { 'mocks': { 'symbol': …, }, }).setup()'''

        _ = unittest.mock.patch('torment.fixtures._find_mocker')
        mocked_fixtures_find_mocker = _.start()
        self.addCleanup(_.stop)
        mocked_fixtures_find_mocker.return_value = lambda: True

        _ = unittest.mock.patch('torment.fixtures._prepare_mock')
        mocked_fixtures_prepare_mock = _.start()
        self.addCleanup(_.stop)

        fixtures.register(self.ns, (fixtures.Fixture, ), {
            'mocks': {
                'symbol': {},
            },
        })

        _ = self.ns[self.class_name](self.context)
        _.setup()

        mocked_fixtures_find_mocker.assert_called_once_with(
            'symbol', self.context)
        mocked_fixtures_prepare_mock.assert_called_once_with(
            self.context, 'symbol')
Esempio n. 2
0
    def test_description_property(self) -> None:
        '''torment.fixtures.register({}, (), { 'description': 'needle', })'''

        fixtures.register(self.ns, ( fixtures.Fixture, ), { 'description': 'needle', })

        _ = self.ns[self.class_name](self.context)

        self.assertEqual(_.description, 'd43830e2e9624dd19c438b15250c5818—stack—needle')
Esempio n. 3
0
    def test_error_property(self) -> None:
        '''torment.fixtures.register({}, (), { 'error': …, })'''

        fixtures.register(self.ns, ( fixtures.Fixture, ), { 'error': { 'class': RuntimeError, }, })

        _ = self.ns[self.class_name](self.context)

        self.assertIsInstance(_.error, RuntimeError)
Esempio n. 4
0
    def test_zero_properties(self) -> None:
        '''torment.fixtures.register({}, (), {})'''

        fixtures.register(self.ns, (fixtures.Fixture, ), {})

        _ = self.ns[self.class_name](self.context)

        self.assertEqual(_.uuid, uuid.UUID('d43830e2e9624dd19c438b15250c5818'))
Esempio n. 5
0
    def test_zero_properties(self) -> None:
        '''torment.fixtures.register({}, (), {})'''

        fixtures.register(self.ns, ( fixtures.Fixture, ), {})

        _ = self.ns[self.class_name](self.context)

        self.assertEqual(_.uuid, uuid.UUID('d43830e2e9624dd19c438b15250c5818'))
Esempio n. 6
0
    def test_one_literal_properties(self) -> None:
        '''torment.fixtures.register({}, (), { 'a': 'a', })'''

        fixtures.register(self.ns, ( fixtures.Fixture, ), { 'a': 'a', })

        _ = self.ns[self.class_name](self.context)

        self.assertEqual(_.a, 'a')
Esempio n. 7
0
    def test_one_function_properties(self) -> None:
        '''torment.fixtures.register({}, (), { 'a': self → None, })'''

        def a(self) -> None: pass  # flake8: noqa (one line function in tests)

        fixtures.register(self.ns, ( fixtures.Fixture, ), { 'a': a, })

        _ = self.ns[self.class_name](self.context)

        self.assertIsNone(_.a)
Esempio n. 8
0
    def test_one_literal_properties(self) -> None:
        '''torment.fixtures.register({}, (), { 'a': 'a', })'''

        fixtures.register(self.ns, (fixtures.Fixture, ), {
            'a': 'a',
        })

        _ = self.ns[self.class_name](self.context)

        self.assertEqual(_.a, 'a')
Esempio n. 9
0
    def test_one_class_properties(self) -> None:
        '''torment.fixtures.register({}, (), { 'a': class, })'''

        class A(object):
            pass

        fixtures.register(self.ns, ( fixtures.Fixture, ), { 'a': A, })

        _ = self.ns[self.class_name](self.context)

        self.assertIsInstance(_.a, A)
Esempio n. 10
0
    def test_description_property(self) -> None:
        '''torment.fixtures.register({}, (), { 'description': 'needle', })'''

        fixtures.register(self.ns, (fixtures.Fixture, ), {
            'description': 'needle',
        })

        _ = self.ns[self.class_name](self.context)

        self.assertEqual(_.description,
                         'd43830e2e9624dd19c438b15250c5818—stack—needle')
Esempio n. 11
0
    def test_one_function_properties(self) -> None:
        '''torment.fixtures.register({}, (), { 'a': self → None, })'''
        def a(self) -> None:
            pass

        fixtures.register(self.ns, (fixtures.Fixture, ), {
            'a': a,
        })

        _ = self.ns[self.class_name](self.context)

        self.assertIsNone(_.a)
Esempio n. 12
0
    def test_error_property(self) -> None:
        '''torment.fixtures.register({}, (), { 'error': …, })'''

        fixtures.register(self.ns, (fixtures.Fixture, ), {
            'error': {
                'class': RuntimeError,
            },
        })

        _ = self.ns[self.class_name](self.context)

        self.assertIsInstance(_.error, RuntimeError)
Esempio n. 13
0
    def test_one_class_properties(self) -> None:
        '''torment.fixtures.register({}, (), { 'a': class, })'''
        class A(object):
            pass

        fixtures.register(self.ns, (fixtures.Fixture, ), {
            'a': A,
        })

        _ = self.ns[self.class_name](self.context)

        self.assertIsInstance(_.a, A)
Esempio n. 14
0
    def test_mocks_mock_property(self) -> None:
        '''torment.fixtures.register({}, (), { 'mocks': { 'symbol': …, }, }).setup()'''

        _ = unittest.mock.patch('torment.fixtures._find_mocker')
        mocked_fixtures_find_mocker = _.start()
        self.addCleanup(_.stop)
        mocked_fixtures_find_mocker.return_value = lambda: True

        _ = unittest.mock.patch('torment.fixtures._prepare_mock')
        mocked_fixtures_prepare_mock = _.start()
        self.addCleanup(_.stop)

        fixtures.register(self.ns, ( fixtures.Fixture, ), { 'mocks': { 'symbol': {}, }, })

        _ = self.ns[self.class_name](self.context)
        _.setup()

        mocked_fixtures_find_mocker.assert_called_once_with('symbol', self.context)
        mocked_fixtures_prepare_mock.assert_called_once_with(self.context, 'symbol')
# Copyright 2015 Alex Brandt
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_helpers import EvertFixture

fixtures.register(globals(), ( EvertFixture, ), {
    'parameters': {
        'iterable': [],
    },

    'expected': [ [], ],
})
Esempio n. 16
0
# Copyright 2015 Alex Brandt
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_helpers import EvertFixture

fixtures.register(globals(), (EvertFixture, ), {
    'parameters': {
        'iterable': [],
    },
    'expected': [
        [],
    ],
})
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_contexts.test_docker.test_compose import ErrorUpFixture

fixtures.register(globals(), ( ErrorUpFixture, ), {
    'function_name': 'up',

    'parameters': {
        'services': (),
    },

    'expected': (
        ( ( 'docker-compose up -d --no-deps', ), {}, ),
    ),

    'error': {
        'class': ValueError,
        'args': ( 'empty iterable passed to up(): []', ),
    },
})
Esempio n. 18
0
from torment import fixtures

from test_torment.test_unit.test_helpers import EvertFixture

fixtures.register(
    globals(), (EvertFixture, ), {
        'parameters': {
            'iterable': [
                {
                    'foo': (
                        True,
                        False,
                    ),
                },
            ],
        },
        'expected': [
            [
                {
                    'foo': True,
                },
            ],
            [
                {
                    'foo': False,
                },
            ],
        ],
    })
from test_torment.test_unit.test_helpers import EvertFixture

fixtures.register(globals(), ( EvertFixture, ), {
    'parameters': {
        'iterable': [
            { 'foo': ( True, False, ), },
            { 'bar': ( True, False, ), },
        ],
    },

    'expected': [
        [
            { 'foo': True, },
            { 'bar': True, },
        ],
        [
            { 'foo': True, },
            { 'bar': False, },
        ],
        [
            { 'foo': False, },
            { 'bar': True, },
        ],
        [
            { 'foo': False, },
            { 'bar': False, },
        ],
    ],
})
# Copyright 2015 Alex Brandt
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_petcd.test_unit import AsyncEtcdClientPropertyFixture

fixtures.register(globals(), ( AsyncEtcdClientPropertyFixture, ), {
    'property': 'follow_redirects',
    'expected': False,
})
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_contexts.test_docker.test_compose import UpFixture

fixtures.register(
    globals(), (UpFixture, ), {
        'function_name':
        'up',
        'parameters': {
            'services': ('foo', ),
        },
        'expected': ((
            ('docker-compose up --no-color -d foo', ),
            {
                'shell': True,
            },
        ), ),
    })
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_decorators import LogDecoratorFixture


def success():
    pass


fixtures.register(
    globals(), (LogDecoratorFixture, ), {
        'function':
        success,
        'parameters': {
            'prefix': 'prefix',
        },
        'expected': [
            'INFO:torment.decorators:STARTING: prefixsuccess()',
            'INFO:torment.decorators:STOPPING: prefixsuccess()',
        ],
    })
from test_petcd import test_helpers
from test_petcd.test_unit import AsyncEtcdClientGetFixture

expected = {
    'key': '/foo',
    'quorum': False,
    'recursive': False,
    'sorted': False,
    'wait': False,
    'wait_index': None,
}

arguments = [
    { 'quorum': ( True, ), },
    { 'recursive': ( True, ), },
    { 'sorted': ( True, ), },
    { 'wait_index': ( 0, 1, ), },
    { 'wait': ( True, ), },
]

for combination in test_helpers.powerset(arguments):
    for subset in test_helpers.evert(combination):
        fixtures.register(globals(), ( AsyncEtcdClientGetFixture, ), {
            'parameters': {
                'kwargs': functools.reduce(helpers.extend, list(subset), { 'key': '/foo', }),
            },

            'expected': functools.reduce(helpers.extend, [ expected ] + list(subset), { 'key': '/foo', }),
        })
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_contexts.test_docker.test_compose import CallWrapperFixture

fixtures.register(
    globals(), (CallWrapperFixture, ), {
        'function_name':
        'found',
        'expected': (
            (
                ('which docker-compose', ),
                {
                    'shell': True,
                },
            ),
            (
                ('docker-compose stop', ),
                {
                    'shell': True,
                },
            ),
        ),
    })
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_helpers import MergeFixture

fixtures.register(globals(), ( MergeFixture, ), {
    'parameters': {
        'base': {
            'a': {
                'a': 'a',
            },
        },
        'extension': {
            'a': {
                'a': 'b',
            },
        },
    },

    'expected': {
        'a': {
            'a': 'b',
        },
    },
})
# Copyright 2015 Alex Brandt
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_petcd.test_unit import AsyncEtcdClientPropertyFixture

fixtures.register(globals(), ( AsyncEtcdClientPropertyFixture, ), {
    'property': 'url',
    'expected': 'http://localhost:7379/v2',
})
# Copyright 2015 Alex Brandt
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_helpers import MergeFixture

fixtures.register(globals(), ( MergeFixture, ), {
    'parameters': {
        'base': {},
        'extension': {},
    },

    'expected': {},
})
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_helpers import ExtendFixture

fixtures.register(globals(), ( ExtendFixture, ), {
    'parameters': {
        'base': {
            'a': 'a',
            'b': 'b',
        },
        'extension': {
            'b': 'y',
            'c': 'c',
        },
    },

    'expected': {
        'a': 'a',
        'b': 'y',
        'c': 'c',
    },
})
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_decorators import LogDecoratorFixture


def failure():
    raise RuntimeError()

fixtures.register(globals(), ( LogDecoratorFixture, ), {
    'function': failure,

    'expected': [
        'INFO:torment.decorators:STARTING: failure()',
        'ERROR:torment.decorators:EXCEPTION: failure()',
        'INFO:torment.decorators:STOPPING: failure()'
    ],
})
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_helpers import PowersetFixture

fixtures.register(
    globals(), (PowersetFixture, ), {
        'parameters': {
            'iterable': [
                1,
                2,
            ],
        },
        'expected': [
            (),
            (1, ),
            (2, ),
            (
                1,
                2,
            ),
        ],
    })
Esempio n. 31
0
# Copyright 2015 Alex Brandt
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_helpers import ExtendFixture

fixtures.register(globals(), ( ExtendFixture, ), {
    'parameters': {
        'base': {
            'a': 'a',
        },
        'extension': {},
    },

    'expected': {
        'a': 'a',
    },
})
# Copyright 2015 Alex Brandt
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_contexts.test_docker.test_compose import CallWrapperFixture

fixtures.register(globals(), ( CallWrapperFixture, ), {
    'function_name': 'stop',

    'expected': (
        ( ( 'docker-compose stop', ), { 'shell': True, }, ),
    ),
})
Esempio n. 33
0
# Copyright 2015 Alex Brandt
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_helpers import MergeFixture

fixtures.register(globals(), (MergeFixture,), {"parameters": {"base": {}, "extension": {}}, "expected": {}})
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_decorators import LogDecoratorFixture


def failure():
    raise RuntimeError()

fixtures.register(globals(), ( LogDecoratorFixture, ), {
    'function': failure,

    'parameters': {
        'prefix': 'prefix',
    },

    'expected': [
        'INFO:torment.decorators:STARTING: prefixfailure()',
        'ERROR:torment.decorators:EXCEPTION: prefixfailure()',
        'INFO:torment.decorators:STOPPING: prefixfailure()',
    ]
})
# Copyright 2015 Alex Brandt
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_decorators import LogDecoratorFixture


def success():
    pass

fixtures.register(globals(), ( LogDecoratorFixture, ), {
    'function': success,

    'expected': [
        'INFO:torment.decorators:STARTING: success()',
        'INFO:torment.decorators:STOPPING: success()',
    ],
})
# Copyright 2015 Alex Brandt
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_petcd.test_unit import AsyncEtcdClientPropertyFixture

fixtures.register(globals(), ( AsyncEtcdClientPropertyFixture, ), {
    'property': 'retries',
    'expected': 0,
})
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_contexts.test_docker.test_compose import UpFixture

fixtures.register(globals(), ( UpFixture, ), {
    'function_name': 'up',

    'parameters': {
        'services': (
            'foo',
        ),
    },

    'expected': (
        ( ( 'docker-compose up -d --no-deps foo', ), { 'shell': True, }, ),
    ),
})
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_decorators import LogDecoratorFixture


def success():
    pass

fixtures.register(globals(), ( LogDecoratorFixture, ), {
    'function': success,

    'parameters': {
        'prefix': 'prefix',
    },

    'expected': [
        'INFO:torment.decorators:STARTING: prefixsuccess()',
        'INFO:torment.decorators:STOPPING: prefixsuccess()',
    ],
})
# Copyright 2015 Alex Brandt
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_helpers import PowersetFixture

fixtures.register(globals(), ( PowersetFixture, ), {
    'parameters': {
        'iterable': [ 1, ],
    },

    'expected': [ (), ( 1, ), ],
})
Esempio n. 40
0
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_decorators import LogDecoratorFixture


def failure():
    raise RuntimeError()


fixtures.register(
    globals(), (LogDecoratorFixture, ), {
        'function':
        failure,
        'parameters': {
            'prefix': 'prefix',
        },
        'expected': [
            'INFO:torment.decorators:STARTING: prefixfailure()',
            'ERROR:torment.decorators:EXCEPTION: prefixfailure()',
            'INFO:torment.decorators:STOPPING: prefixfailure()',
        ]
    })
Esempio n. 41
0
# Copyright 2015 Alex Brandt
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_helpers import ExtendFixture

fixtures.register(
    globals(), (ExtendFixture,), {"parameters": {"base": {"a": "a"}, "extension": {}}, "expected": {"a": "a"}}
)
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torment import fixtures

from test_torment.test_unit.test_decorators import LogDecoratorFixture


def failure():
    raise RuntimeError()


fixtures.register(
    globals(), (LogDecoratorFixture, ), {
        'function':
        failure,
        'expected': [
            'INFO:torment.decorators:STARTING: failure()',
            'ERROR:torment.decorators:EXCEPTION: failure()',
            'INFO:torment.decorators:STOPPING: failure()'
        ],
    })