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_allowed_types():
"""Only lists and dicts are allowed."""
utilities.compare_schemas(['one'], ['one'])
utilities.compare_schemas({'one': 'two'}, {'one': 'two'})
with pytest.raises(RuntimeError):
utilities.compare_schemas(('tuple',), ('tuple',))
with pytest.raises(RuntimeError):
utilities.compare_schemas({'this_is': 'dict'}, ['list'])
assert utilities.compare_schemas('string', 'string')
assert utilities.compare_schemas(42, 42)
assert utilities.compare_schemas(23.0, 23.0)
assert utilities.compare_schemas(True, True)
assert not utilities.compare_schemas('string', 'other string')
assert not utilities.compare_schemas(42, 1)
assert not utilities.compare_schemas(23.0, 24.0)
assert not utilities.compare_schemas(True, False)
def test_basic_comparison():
assert utilities.compare_schemas({'one': 'value'}, {'one': 'value'})
assert utilities.compare_schemas(['one', 'two'], ['one', 'two'])
assert utilities.compare_schemas(['one', 'two'], ['two', 'one'])
with pytest.raises(RuntimeError):
utilities.compare_schemas(('tuple',), ('tuple',))
with pytest.raises(RuntimeError):
utilities.compare_schemas({'this_is': 'dict'}, ['list'])
assert utilities.compare_schemas('string', 'string')
assert utilities.compare_schemas(42, 42)
assert utilities.compare_schemas(23.0, 23.0)
assert utilities.compare_schemas(True, True)
assert not utilities.compare_schemas('string', 'other string')
assert not utilities.compare_schemas(42, 1)
assert not utilities.compare_schemas(23.0, 24.0)
assert not utilities.compare_schemas(True, False)
"""Only lists and dicts are allowed."""
utilities.compare_schemas(['one'], ['one'])
utilities.compare_schemas({'one': 'two'}, {'one': 'two'})
with pytest.raises(RuntimeError):
utilities.compare_schemas(('tuple',), ('tuple',))
with pytest.raises(RuntimeError):
utilities.compare_schemas({'this_is': 'dict'}, ['list'])
assert utilities.compare_schemas('string', 'string')
assert utilities.compare_schemas(42, 42)
assert utilities.compare_schemas(23.0, 23.0)
assert utilities.compare_schemas(True, True)
assert not utilities.compare_schemas('string', 'other string')
assert not utilities.compare_schemas(42, 1)
assert not utilities.compare_schemas(23.0, 24.0)
assert not utilities.compare_schemas(True, False)
def test_basic_comparison():
assert utilities.compare_schemas({'one': 'value'}, {'one': 'value'})
assert utilities.compare_schemas(['one', 'two'], ['one', 'two'])
assert utilities.compare_schemas(['one', 'two'], ['two', 'one'])
utilities.compare_schemas(['one'], ['one'])
utilities.compare_schemas({'one': 'two'}, {'one': 'two'})
with pytest.raises(RuntimeError):
utilities.compare_schemas(('tuple',), ('tuple',))
with pytest.raises(RuntimeError):
utilities.compare_schemas({'this_is': 'dict'}, ['list'])
assert utilities.compare_schemas('string', 'string')
assert utilities.compare_schemas(42, 42)
assert utilities.compare_schemas(23.0, 23.0)
assert utilities.compare_schemas(True, True)
assert not utilities.compare_schemas('string', 'other string')
assert not utilities.compare_schemas(42, 1)
assert not utilities.compare_schemas(23.0, 24.0)
assert not utilities.compare_schemas(True, False)
utilities.compare_schemas({'one': 'two'}, {'one': 'two'})
with pytest.raises(RuntimeError):
utilities.compare_schemas(('tuple',), ('tuple',))
with pytest.raises(RuntimeError):
utilities.compare_schemas({'this_is': 'dict'}, ['list'])
assert utilities.compare_schemas('string', 'string')
assert utilities.compare_schemas(42, 42)
assert utilities.compare_schemas(23.0, 23.0)
assert utilities.compare_schemas(True, True)
assert not utilities.compare_schemas('string', 'other string')
assert not utilities.compare_schemas(42, 1)
assert not utilities.compare_schemas(23.0, 24.0)
assert not utilities.compare_schemas(True, False)
def test_allowed_types():
"""Only lists and dicts are allowed."""
utilities.compare_schemas(['one'], ['one'])
utilities.compare_schemas({'one': 'two'}, {'one': 'two'})
with pytest.raises(RuntimeError):
utilities.compare_schemas(('tuple',), ('tuple',))
with pytest.raises(RuntimeError):
utilities.compare_schemas({'this_is': 'dict'}, ['list'])
assert utilities.compare_schemas('string', 'string')
assert utilities.compare_schemas(42, 42)
assert utilities.compare_schemas(23.0, 23.0)
assert utilities.compare_schemas(True, True)
assert not utilities.compare_schemas('string', 'other string')
assert not utilities.compare_schemas(42, 1)
assert not utilities.compare_schemas(23.0, 24.0)
assert not utilities.compare_schemas(True, False)
def test_generate_circular_schema():
schema = Primary.to_json_schema()
pattern = get_fixture('schema_circular.json')
assert compare_schemas(pattern, schema) is True
def test_generate_circular_schema2():
schema = Filesystem.to_json_schema()
pattern = get_fixture('schema_circular2.json')
assert compare_schemas(pattern, schema) is True