How to use the testfixtures.ShouldRaise function in testfixtures

To help you get started, we’ve selected a few testfixtures examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Yelp / pgctl / tests / unit / cli.py View on Github external
def test_nonsense(in_example_dir):
    with ShouldRaise(SystemExit(2)):
        main(['nonsense'])
github Simplistix / configurator / tests / test_mapping.py View on Github external
def test_attr_nested_not_present(self):
        data = Namespace()
        with ShouldRaise(NotPresent('x')):
           load(data, required(source.x.y))
github Simplistix / mush / tests / test_requires.py View on Github external
def test_when_not_type(self):
        obj = Type1()
        w = when(obj)
        with ShouldRaise(AttributeError(
                "'Type1' object has no attribute '__name__'"
                )):
            repr(w)
github Simplistix / mush / tests / test_dependencies.py View on Github external
def test_circular(self):
        class T1(object): pass
        class T2(object): pass
        class T3(object): pass

        def f1(): return T1()
        def f2(t1, t3): return T2()
        def f3(t2): return T3()

        runner = Runner()
        runner.add(f1)
        runner.add(f2, T1, T3)
        runner.add(f3, T2)

        with ShouldRaise(KeyError(
                "'No T3 in context' attempting to call "+repr(f2)
                )):
            runner()
github Simplistix / configurator / tests / test_node.py View on Github external
def test_items_list(self):
        config = ConfigNode([])
        expected = "'list' object has no attribute 'items'"
        with ShouldRaise(AttributeError(expected)):
            tuple(config.items())
github Simplistix / configurator / tests / test_section.py View on Github external
def test_dict_getitem_not_there(self):
        with ShouldRaise(KeyError('foo')):
            self.s['foo']
github Simplistix / configurator / tests / test_config.py View on Github external
def test_failure(self):
        with ShouldRaise(type_error(
            "Cannot merge  with "
        )):
            Config({'foo': 'bar'}) + 1
github Simplistix / configurator / tests / test_mapping.py View on Github external
def test_set_on_required(self):
        data = '1'
        with ShouldRaise(TypeError('Cannot use required() as target')):
            store(data, required(target), 'y')
github Simplistix / configurator / tests / test_mapping.py View on Github external
def test_root(self):
        data = {'foo'}
        with ShouldRaise(TypeError('Cannot store at root')):
            store(data, target, 'foo')
        compare(data, expected={'foo'})
github drillbits / pycure / tests / test_girl.py View on Github external
def test_invalid_partner(self):
        girl1 = self._getTarget(
            'ねじめ',
            'キュアドリル',
            'はい')
        girl2 = self._getTarget(
            'じろう',
            'キュアビッツ',
            'はいじゃないが')
        girl1.partner = girl2
        girl2.partner = girl1
        from pycure.girl import PartnerInvalidError
        with ShouldRaise(PartnerInvalidError):
            self._callFUT(girl1, 'しろう', False)