Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
with pytest.raises(TypeError):
Perm.from_iterable_validated(101)
with pytest.raises(TypeError):
Perm.from_iterable_validated(-234)
with pytest.raises(TypeError):
Perm.from_iterable_validated(None)
with pytest.raises(TypeError):
Perm.from_iterable_validated([0.1, 0.2, 0.3])
with pytest.raises(ValueError):
Perm.from_iterable_validated("132")
with pytest.raises(ValueError):
Perm.from_iterable_validated("134")
with pytest.raises(ValueError):
Perm.from_iterable_validated("112")
with pytest.raises(ValueError):
Perm.from_iterable_validated("5")
try:
Perm.from_iterable_validated(())
Perm.from_iterable_validated((1, 0))
Perm.from_iterable_validated([5, 1, 0, 2, 4, 3])
Perm.from_iterable_validated("1302")
except (ValueError, TypeError):
pytest.fail("Exception raised when it shouldn't")
Perm.from_iterable_validated(None)
with pytest.raises(TypeError):
Perm.from_iterable_validated([0.1, 0.2, 0.3])
with pytest.raises(ValueError):
Perm.from_iterable_validated("132")
with pytest.raises(ValueError):
Perm.from_iterable_validated("134")
with pytest.raises(ValueError):
Perm.from_iterable_validated("112")
with pytest.raises(ValueError):
Perm.from_iterable_validated("5")
try:
Perm.from_iterable_validated(())
Perm.from_iterable_validated((1, 0))
Perm.from_iterable_validated([5, 1, 0, 2, 4, 3])
Perm.from_iterable_validated("1302")
except (ValueError, TypeError):
pytest.fail("Exception raised when it shouldn't")
with pytest.raises(ValueError):
Perm.from_iterable_validated([0, 0])
with pytest.raises(ValueError):
Perm.from_iterable_validated([1])
with pytest.raises(ValueError):
Perm.from_iterable_validated((1,))
with pytest.raises(TypeError):
Perm.from_iterable_validated(101)
with pytest.raises(TypeError):
Perm.from_iterable_validated(-234)
with pytest.raises(TypeError):
Perm.from_iterable_validated(None)
with pytest.raises(TypeError):
Perm.from_iterable_validated([0.1, 0.2, 0.3])
with pytest.raises(ValueError):
Perm.from_iterable_validated("132")
with pytest.raises(ValueError):
Perm.from_iterable_validated("134")
with pytest.raises(ValueError):
Perm.from_iterable_validated("112")
with pytest.raises(ValueError):
Perm.from_iterable_validated("5")
try:
Perm.from_iterable_validated(())
Perm.from_iterable_validated((1, 0))
Perm.from_iterable_validated([5, 1, 0, 2, 4, 3])
Perm.from_iterable_validated("1302")
except (ValueError, TypeError):
pytest.fail("Exception raised when it shouldn't")
with pytest.raises(ValueError):
Perm.from_iterable_validated([0, 1, 1])
with pytest.raises(ValueError):
Perm.from_iterable_validated([1, 0, 1])
with pytest.raises(ValueError):
Perm.from_iterable_validated([0, 0])
with pytest.raises(ValueError):
Perm.from_iterable_validated([1])
with pytest.raises(ValueError):
Perm.from_iterable_validated((1,))
with pytest.raises(TypeError):
Perm.from_iterable_validated(101)
with pytest.raises(TypeError):
Perm.from_iterable_validated(-234)
with pytest.raises(TypeError):
Perm.from_iterable_validated(None)
with pytest.raises(TypeError):
Perm.from_iterable_validated([0.1, 0.2, 0.3])
with pytest.raises(ValueError):
Perm.from_iterable_validated("132")
with pytest.raises(ValueError):
Perm.from_iterable_validated("134")
with pytest.raises(ValueError):
Perm.from_iterable_validated("112")
with pytest.raises(ValueError):
Perm.from_iterable_validated("5")
try:
Perm.from_iterable_validated(())
Perm.from_iterable_validated((1, 0))
Perm.from_iterable_validated([5, 1, 0, 2, 4, 3])
Perm.from_iterable_validated("1302")
except (ValueError, TypeError):
def test_from_iterable_validated():
with pytest.raises(ValueError):
Perm.from_iterable_validated([0, 1, 1])
with pytest.raises(ValueError):
Perm.from_iterable_validated([1, 0, 1])
with pytest.raises(ValueError):
Perm.from_iterable_validated([0, 0])
with pytest.raises(ValueError):
Perm.from_iterable_validated([1])
with pytest.raises(ValueError):
Perm.from_iterable_validated((1,))
with pytest.raises(TypeError):
Perm.from_iterable_validated(101)
with pytest.raises(TypeError):
Perm.from_iterable_validated(-234)
with pytest.raises(TypeError):
Perm.from_iterable_validated(None)
with pytest.raises(TypeError):
Perm.from_iterable_validated([0.1, 0.2, 0.3])
with pytest.raises(ValueError):
Perm.from_iterable_validated([1])
with pytest.raises(ValueError):
Perm.from_iterable_validated((1,))
with pytest.raises(TypeError):
Perm.from_iterable_validated(101)
with pytest.raises(TypeError):
Perm.from_iterable_validated(-234)
with pytest.raises(TypeError):
Perm.from_iterable_validated(None)
with pytest.raises(TypeError):
Perm.from_iterable_validated([0.1, 0.2, 0.3])
with pytest.raises(ValueError):
Perm.from_iterable_validated("132")
with pytest.raises(ValueError):
Perm.from_iterable_validated("134")
with pytest.raises(ValueError):
Perm.from_iterable_validated("112")
with pytest.raises(ValueError):
Perm.from_iterable_validated("5")
try:
Perm.from_iterable_validated(())
Perm.from_iterable_validated((1, 0))
Perm.from_iterable_validated([5, 1, 0, 2, 4, 3])
Perm.from_iterable_validated("1302")
except (ValueError, TypeError):
pytest.fail("Exception raised when it shouldn't")
def parse_basis(args):
basis = []
for perm_str in args.basis.split("_"):
perm_tuple = tuple(map(int, perm_str))
if 0 not in perm_tuple:
perm_tuple = tuple(i - 1 for i in perm_tuple)
perm = Perm.from_iterable_validated(perm_tuple)
basis.append(perm)
return basis