Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_nonsense(in_example_dir):
with ShouldRaise(SystemExit(2)):
main(['nonsense'])
def test_attr_nested_not_present(self):
data = Namespace()
with ShouldRaise(NotPresent('x')):
load(data, required(source.x.y))
def test_when_not_type(self):
obj = Type1()
w = when(obj)
with ShouldRaise(AttributeError(
"'Type1' object has no attribute '__name__'"
)):
repr(w)
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()
def test_items_list(self):
config = ConfigNode([])
expected = "'list' object has no attribute 'items'"
with ShouldRaise(AttributeError(expected)):
tuple(config.items())
def test_dict_getitem_not_there(self):
with ShouldRaise(KeyError('foo')):
self.s['foo']
def test_failure(self):
with ShouldRaise(type_error(
"Cannot merge with "
)):
Config({'foo': 'bar'}) + 1
def test_set_on_required(self):
data = '1'
with ShouldRaise(TypeError('Cannot use required() as target')):
store(data, required(target), 'y')
def test_root(self):
data = {'foo'}
with ShouldRaise(TypeError('Cannot store at root')):
store(data, target, 'foo')
compare(data, expected={'foo'})
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)